Bug 167722 - C code written to use static string pointers to initialized strings from some function calls fails with a segmentation fault.
C code written to use static string pointers to initialized strings from some...
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
4
x86_64 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-09-07 12:34 EDT by Norman R. Weathers
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-09-07 12:42:42 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)
C code snippet that fails everytime on latest glibc update x86_64 bit Opteron (573 bytes, text/plain)
2005-09-07 12:36 EDT, Norman R. Weathers
no flags Details
GDB output from test case segmentation fault (1.80 KB, text/plain)
2005-09-07 12:38 EDT, Norman R. Weathers
no flags Details

  None (edit)
Description Norman R. Weathers 2005-09-07 12:34:15 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.10) Gecko/20050720 Fedora/1.0.6-1.1.fc4 Firefox/1.0.6

Description of problem:
Simple programs that use statically allocated strings are failing with segmentation faults due to, according to gdb, strlen function calls.

(I will attach a code snippet and gdb output that I have from the code runs).

Version-Release number of selected component (if applicable):
glibc-2.3.5-10.3

How reproducible:
Always

Steps to Reproduce:
1. Compile code snippet (latest updated glibc)
2. Run program and see segmentation fault

  

Actual Results:  Segmentation fault (core dumped)


Expected Results:  The Time is:   Wed Sep  7 11:26:51 2005

The Time is:    Wed Sep  7 11:26:51 2005

STDOUT -- The Timeis:    Wed Sep  7 11:26:51 2005

The time is:   Wed Sep  7 11:26:51 2005


Where the time would change at every program invocation.

Additional info:

This did not start happening until after I did a yum update of a glibc change recently.  The problem can be caused by using fprintf to any output, or if you use a static char string initialized by a function call (example, ctime), then it appears to crash all the time (the times I have tried, anyway).
Comment 1 Norman R. Weathers 2005-09-07 12:36:41 EDT
Created attachment 118568 [details]
C code snippet that fails everytime on latest glibc update x86_64 bit Opteron
Comment 2 Norman R. Weathers 2005-09-07 12:38:10 EDT
Created attachment 118569 [details]
GDB output from test case segmentation fault

This attachment is a gdb of the core file that I had when I ran my test case.
Comment 3 Jakub Jelinek 2005-09-07 12:42:42 EDT
This is a bug in your testcase.
You should look at warnings GCC reports before filling bug reports.
On this testcase, GCC complains
warning: cast to pointer from integer of different size
on the
char *time1 = (char *) ctime (&current_time);
line.  That's not too surprising, as ctime is prototyped not in sys/time.h,
but in time.h.  And, without a prototype, the implicit prototype is
extern int ctime ();
so the upper 32 bits of time1 will be likely different from what you'd expect.

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