delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/12/11/14:58:48

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
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
MIME-Version: 1.0
Subject: segmentation fault in socket()
Date: Wed, 11 Dec 2002 13:58:12 -0600
Message-ID: <FED2EC3075A99C4CBB8D63AABBC3396E1FAFF5@daa21794exc001.divine.com>
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
From: "Madsen, Mark" <Mark DOT Madsen AT divine DOT com>
To: <cygwin AT cygwin DOT com>
X-OriginalArrivalTime: 11 Dec 2002 19:58:12.0326 (UTC) FILETIME=[A2A8E060:01C2A14F]
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 <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <cygwin/in.h>


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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019