Package: 2.20.1-10 Version: trivial c program segfaults on strlen when linked with binutils-gold Severity: important
Hi, when compiling small programm (attached below) and linking with binutils-gold, program segfaults whenever there is a call to strlen. gdb shows me: (gdb) where #0 0x0000000000401a00 in strlen () #1 0x00000000004005dc in main () I do not get additional informations when installing libc6-dbg I'm using libc6 and libc6-dev 2.11.1-2 from unstable, and gcc 4.4.4-4 also from unstable. my architecture is amd64 and uname -r is: 2.6.32-trunk-amd64 The problem disappears when removing binutils-gold package. -- System Information: Debian Release: squeeze/sid APT prefers unstable APT policy: (990, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 2.6.32-trunk-amd64 (SMP w/2 CPU cores) Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages binutils-gold depends on: ii binutils 2.20.1-10 The GNU assembler, linker and bina binutils-gold recommends no packages. binutils-gold suggests no packages.
// gcc -o test test.c #include <stdio.h> #include <string.h> int main(int argc, char **argv) { const char *path = argv[0]; // all those path definitions will result in a crash in strlen //const char* path = "path\0"; //const char* path = "path"; //const char* path = strdup(argv[0]); // prints command name correctly printf("command is: %s\n", path); int i = 0; for (i = 0; i < 1020; i++) { if (path[i] == '\0') { break; } } // prints correct string length printf("computed length: %d\n", i); // crashes: // (gdb) where // #0 0x0000000000401a00 in strlen () // #1 0x00000000004005dc in main () printf("command length: %d\n", strlen(path)); return 0; }