segfault with strerror / no result with strerror_r when some headers are not included
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
glibc (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Hi,
I'm using libc6 version 2.9-4ubuntu6.1. in Ubuntu 9.04.
I'm using the strerror_r function to interpret an error code as a string. This does not work (anymore). I always get an empty error message.Then I tried to use strerror directly, but when I try to touch the returned string I get a segfault. perror is working.
from dmesg:
[ 1584.217867] GlobalPlatformT
I found this link which offers a quick fix:
https:/
I quote:
This particular bug is caused by the lack of the correct header definitions in the C file. The implicit declarations are breaking things on a 64-bit architecture.
So when I use these headers:
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <syslog.h>
#include <sys/ioctl.h>
#include <string.h>
it works.
But with the old includes:
#include <stdio.h>
#include <errno.h>
it does not work.
This behaviour is inconsistent with 32 bit systems and unexpected. The compiler and linker are reporting no error.
Why is this happening? You can fix this strange behavior?