Bug 131419 - wcswcs returns invalid address
wcswcs returns invalid address
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: glibc (Show other bugs)
3.0
ia64 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-09-01 03:14 EDT by Need Real Name
Modified: 2007-11-30 17:07 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-09-01 04:59:25 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
C program (908 bytes, text/plain)
2004-09-01 03:18 EDT, Need Real Name
no flags Details

  None (edit)
Description Need Real Name 2004-09-01 03:14:56 EDT
Description of problem:
wchar_t *wcswcs(wchar_t *, wchar_t *) does not return valid address.

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

glibc-2.3.2-95.6
gcc-3.2.3-24
Architecture used is Itanium 2.

How reproducible:
Please find the test case attached to this bug report.

Steps to Reproduce:
1. Compile the C test case using:
gcc test.c
2. Run the executable a.out
./a.out

  
Actual results:
Segmentation fault (core dumped)

Expected results:
Len=3

Additional info:
The same test case works on i686 and fails on ia64
Comment 1 Need Real Name 2004-09-01 03:18:00 EDT
Created attachment 103331 [details]
C program

This is a C program to reproduce the problem
Comment 2 Jakub Jelinek 2004-09-01 04:59:25 EDT
It always help to compile with warnings enabled.
gcc -Wall test.c
test.c: In function `main':
test.c:13: warning: implicit declaration of function `mbstowcs'
test.c:17: warning: implicit declaration of function `wcswcs'
test.c:17: warning: assignment makes pointer from integer without a cast
test.c:31: warning: implicit declaration of function `wcstombs'
test.c:32: warning: implicit declaration of function `strlen'
test.c:33: warning: int format, different type arg (arg 2)

makes it clear that you are missing some includes
(particularly
#include <string.h>
#include <stdlib.h>
) and also, given that wcswcs is a X/Open only function (ISO C99
uses wcsstr), you need to enable X/Open feature set, see info libc
on Feature Set Macros.
I.e. if you add those two includes and compile with -D_XOPEN_SOURCE,
-D_GNU_SOURCE, -D_XOPEN_SOURCE=600 or similar, it will work just fine.

Unprototyped functions are assumed to return int, so really bad things
happen on 64-bit arches for functions which return pointers or other
64-bit values or on all arches if they return floating point values
and prototypes aren't used.

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