Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Subject: segmentation fault in socket() Date: Wed, 11 Dec 2002 13:58:12 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: From: "Madsen, Mark" To: X-OriginalArrivalTime: 11 Dec 2002 19:58:12.0326 (UTC) FILETIME=[A2A8E060:01C2A14F] Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id gBBJwlC29240 This is another problem that I encountered while looking into the segment fault in select() (see thread: crash in select). The following code will run until it generates a segmentation fault somewhere in the call to socket(). The final few lines of the resulting output are after the code sample. It's interesting to note that there are errors resulting from cmalloc returning NULL, but a valid socket descriptor is still returned. This was run on 1.3.17 on W2K Pro. Sample below: ---------------------------------------------------- #include #include #include #include int main() { int sd; while(1) { printf("Attempting to create next socket.\n"); if ( ( sd = socket( PF_INET, SOCK_STREAM, 0 ) ) <= 0 ) { printf("Can not get socket!\n"); } else { printf("Opened socket: %d\n",sd); } // Adding a delay here didn't change the results. } return 0; } Output: ------- . . . Attempting to create next socket. Opened socket: 2611 Attempting to create next socket. Opened socket: 2612 Attempting to create next socket. 6 [main] test2 7012 cmalloc: cmalloc returned NULL Opened socket: 2613 Attempting to create next socket. 101556 [main] test2 7012 cmalloc: cmalloc returned NULL 101750 [main] test2 7012 cmalloc: cmalloc returned NULL Segmentation fault (core dumped) -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/