Bug 167722 - C code written to use static string pointers to initialized strings from some function calls fails with a segmentation fault.
Summary: C code written to use static string pointers to initialized strings from some...
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc   
(Show other bugs)
Version: 4
Hardware: x86_64 Linux
medium
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-09-07 16:34 UTC by Norman R. Weathers
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-09-07 16:42:42 UTC
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 16:36 UTC, Norman R. Weathers
no flags Details
GDB output from test case segmentation fault (1.80 KB, text/plain)
2005-09-07 16:38 UTC, Norman R. Weathers
no flags Details

Description Norman R. Weathers 2005-09-07 16:34:15 UTC
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 16:36:41 UTC
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 16:38:10 UTC
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 16:42:42 UTC
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.