segfault with strerror / no result with strerror_r when some headers are not included

Bug #515209 reported by Karsten on 2010-01-31
This bug affects 1 person
Affects Status Importance Assigned to Milestone
glibc (Ubuntu)

Bug Description


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[5311]: segfault at ffffffffd78fcdc2 ip 00007fb6d7844c40 sp 00007fffc8d08138 error 4 in[7fb6d77c4000+168000]

I found this link which offers a quick fix:

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?

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers