This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/1377] New: seg fault inside getwc() when using LD_PRELOADed code
- From: "manuelarriaga at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 23 Sep 2005 22:09:35 -0000
- Subject: [Bug libc/1377] New: seg fault inside getwc() when using LD_PRELOADed code
- Reply-to: sourceware-bugzilla at sourceware dot org
A segmentation fault occurs inside getwc() if this function is called on a file
pointer obtained from a preloaded fopen() which merely returns the (FILE*)
pointer returned by the glibc fopen().
System: Linux kernel 2.6.11.4, gcc 3.3.4
To replicate:
1) compile the following code snippet
/*
Compiled with
gcc -Wall -W -D_REENTRANT libtest.c -nostartfiles -shared -fPIC
-Wl,-soname,libtest.so -o libtest.so -ldl
*
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <dlfcn.h>
FILE *fopen(const char *path, const char *mode)
{
FILE * (*real_fopen) (const char*,const char*);
real_fopen = dlsym(RTLD_NEXT, "fopen");
if (!real_fopen)
{
printf("dlsym() failed\n.");
return NULL;
}
printf("invoking real fopen\n");
return (*real_fopen)(path,mode);
}
2) compile the following test program
/*
Compiled with
gcc -o test test.c
*/
#include <stdio.h>
#include <wchar.h>
int main (void)
{
FILE *fp = fopen("abcd", "r");
if (!fp)
{
printf("inside test program: fp == NULL, quitting.\n");
return 0;
}
wint_t w = getwc(fp);
return 0;
}
3) run
LD_PRELOAD=./libtest.so ./test
This generates a segmentation fault inside getwc().
--
Summary: seg fault inside getwc() when using LD_PRELOADed code
Product: glibc
Version: 2.3.4
Status: NEW
Severity: critical
Priority: P1
Component: libc
AssignedTo: gotom at debian dot or dot jp
ReportedBy: manuelarriaga at gmail dot com
CC: glibc-bugs at sources dot redhat dot com,manuelarriaga
at gmail dot com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=1377
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.