Bug 99124 - Linking with pthreads causes crash even without using any thread functions
Linking with pthreads causes crash even without using any thread functions
Status: CLOSED WORKSFORME
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
8.0
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-07-14 15:41 EDT by Ajay S
Modified: 2016-11-24 10:26 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-07-18 09:45:02 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Ajay S 2003-07-14 15:41:49 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030314

Description of problem:
Having a large stack variable causes a crash when the program is linked with the
pthread library, even when no threading is done!
Take this sample code:
// ----------------------------------------c-u-t----h-e-r-e-----------
#include <stdio.h>

#ifndef BIG
#define BIG 4*1024*1024
#endif

main () {
        char foobar[BIG];

        memset(foobar, 'A', BIG);
        fprintf(stderr,"declared: '%c'..'%c'\n", foobar[0], foobar[BIG-1]);
}
// ----------------------------------------c-u-t---h-e-r-e------------

% gcc bug.c -o bug -g
% ./bug
declared: 'A'..'A'
(works)

% gcc bug.c -o bug -g -lpthread
% ./bug
Segmentation fault




Version-Release number of selected component (if applicable):
glibc-2.3.2-4.80.6
gcc-3.2-7

How reproducible:
Always

Steps to Reproduce:
1. Compile sample code (above) with "-lpthread"
2. Run
3. Profit!!! err... I mean, "Segmentation Fault"
    

Actual Results:  Segmentation fault

Expected Results:  Should print:
declared: 'A'..'A'

Additional info:
% gcc --version
gcc (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Comment 1 Jakub Jelinek 2003-07-18 09:45:02 EDT
You have not specificed what exact libpthread you are using.
If /lib/i686/libpthread.so.0, then it should work just fine when using default
ulimit -s. /lib/libpthread.so.0 will expectedly segfault, it has to limit
stack sizes of each thread (including initial one) to 2M.

Note You need to log in before you can comment on or make changes to this bug.