delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/02/10/07:40:35

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=0.4 required=5.0 tests=AWL,BAYES_00,TW_DB,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
From: Manuel Wienand <Manuel DOT Wienand AT ubitronix DOT com>
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Date: Fri, 10 Feb 2012 13:40:07 +0100
Subject: RE: cygwin > 1.7.9: Segmentation faults / STATUS_STACK_OVERFLOW
Message-ID: <0C11C5BF0B29FD43A8D0250F711D497F89E1DD5886@ex01-ubitronix.ubitronix.local>
References: <0C11C5BF0B29FD43A8D0250F711D497F89E1DD585C AT ex01-ubitronix DOT ubitronix DOT local> <20120207164548 DOT GD3178 AT calimero DOT vinschen DOT de>
In-Reply-To: <20120207164548.GD3178@calimero.vinschen.de>
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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-MIME-Autoconverted: from base64 to 8bit by delorie.com id q1ACeT7q019117

Hi Corinna,

ok, the STATUS_STACK_OVERFLOW problem is solved. Seems like a local variable with about 540 KiB caused the overflow. The Cygwin Shell gives me 2034 for "limit -s" Is that the correct maximum stack size in KiB that is relevant for me?

Now about the segmentation fault. It seems like the problem only occurs when calling glob in an own thread, using some special search string and only during gdb debugging. See the test case below, I hope it helps.

Thanks in advance.

Regards,
Manuel


#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <pthread.h>
#include <glob.h>

pthread_t threadId;

void * callGlob(void * data)
{
  glob_t    info;
  int i;
  char searchStr[] = "/proc/[0-9]*/cmdline"; // Crashing on debug
  //char searchStr[] = "/proc/1234/cmdline";
  //char searchStr[] = "*.no";
  //char searchStr[] = "./Debug/*.exe";

  glob(searchStr, GLOB_NOSORT, NULL, &info );
  printf("Found %d files.\n", info.gl_matchc);
  for (i=0; i<info.gl_matchc; i++)
  {
    printf("Found: %s\n", info.gl_pathv[i]);
  }
  globfree(&info);
  return NULL;
}

int main(void)
{
  int ret;
  puts("Starting test");

#if 0
  // Working fine if called in the main thread.
  callGlob(NULL);
#else
  // Not working if called in another thread.
  ret = pthread_create(&threadId, NULL, callGlob, NULL);
  if( ret != 0 )
  {
    printf("pthread_create failed: %s %d\n",sys_errlist[ret],ret);
    return(EXIT_FAILURE);
  }
#endif

  printf("Waiting for thread.\n");
  pthread_join(threadId, NULL);
  printf("Thread finished.\n");

  return EXIT_SUCCESS;
}

> -----Original Message-----
> From: Corinna Vinschen
> Sent: Tuesday, February 07, 2012 5:46 PM
> Subject: Re: cygwin > 1.7.9: Segmentation faults / STATUS_STACK_OVERFLOW
> 
> On Feb  7 17:31, Manuel Wienand wrote:
> > Hi,
> >
> > I have the problem that I get a segmentation fault on the newer versions of
> the cygwin1.dll when debugging and a STATUS_STACK_OVERFLOW exception when
> running without debugger.
> > I did an update of my cygwin stuff on Monday, and I'm using the latest
> snapshot dll. I'm quite sure it has something to do with the dll, because I
> did clean and rebuild with newest
> > cygwin versions. Since this wasn't working, I got my old dll (from
> 29.03.2011) and it worked again.  I tried some other snapshot versions (up to
> 04.06.2011, since there are no old ones),
> > but none of them worked.
> >
> > If I can get older snapshot versions, I might be able to track it down. But
> then again stack problems are hard to catch.
> > I compiled my code with -fstack-protector-all --param ssp-buffer-size=4, but
> this didn't help me so far (well, maybe I'm not using it right.).
> >
> > Stacktrace of the first segmentation fault:
> > Thread [11] 0 (Suspended : Signal : SIGSEGV:Segmentation fault)
> > _alloca() at ../../../libgcc/../gcc/config/i386/cygwin.asm:45 0x6116fd02
> > __small_vswprintf() at /netrel/src/cygwin-snapshot-20120202-
> 1/winsup/cygwin/smallprint.cc:369 0x610dbdfe
> > 0x0
> 
> Can you please create a simple testcase, in plain C, which allows to
> reproduce the problem with minimal code?
> 
> 
> Thanks,
> Corinna
> 
> --
> Corinna Vinschen                  Please, send mails regarding Cygwin to
> Cygwin Project Co-Leader          cygwin AT cygwin DOT com
> Red Hat
> 
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> 
> 
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.


- Raw text -


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