Re: segfaults on amd64
On Sat, Feb 25, 2006 at 08:12:03PM +0100, Petr Salinger wrote: > The bug is fixed only partially, it is still in kernel, > now it affect only DYN object, > EXEC are (on kfreebsd-i386) mapped correctly. > > Can you, please, test also following: > > > #include > #include > > char buf[4096]; > > int main() > { > int fd, cnt; > fd = open("/proc/self/maps", O_RDONLY); > cnt = read(fd, buf, 4096); > write(1, buf, cnt); > _exit(123); > } > $ .maps 0040-00401000 r-xp 3000 00:00 353289 /tmp/maps 0050-00502000 rw-p 2000 00:00 0 80050-800517000 r-xp 0008f000 00:00 168361 /gnu/lib/ld-2.3.6.so 800517000-800519000 rw-p 2000 00:00 0 800616000-800617000 r--p 0008f000 00:00 168361 /gnu/lib/ld-2.3.6.so 800617000-800618000 rw-p 1000 00:00 0 800618000-800731000 r-xp 0083f000 00:00 168360 /gnu/lib/libc-2.3.6.so 800731000-80083 ---p 0083f000 00:00 168360 /gnu/lib/libc-2.3.6.so 80083-800834000 r--p 0083f000 00:00 168360 /gnu/lib/libc-2.3.6.so 800834000-800836000 rw-p 0083f000 00:00 168360 /gnu/lib/libc-2.3.6.so 800836000-80083a000 rw-p 4000 00:00 0 7ffe-8000 rwxp 0002 00:00 0 -- Robert Millan -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: segfaults on amd64
On Sat, Feb 25, 2006 at 09:08:33PM +0100, Petr Salinger wrote: > Robert, > > can you please also try > > LD_SHOW_AUXV=all /lib/ld-kfreebsd-x86-64.so.1 $ LD_SHOW_AUXV=all /lib/ld-kfreebsd-x86-64.so.1 AT_PHDR: 0x40 AT_PHENT:56 AT_PHNUM:6 AT_PAGESZ: 4096 AT_FLAGS:0x0 AT_ENTRY:0xca0 AT_BASE: 0x800116000 Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...] You have invoked `ld.so', the helper program for shared library executables. [...] > LD_SHOW_AUXV=all ./test $ LD_SHOW_AUXV=all ./test AT_PHDR: 0x400040 AT_PHENT:56 AT_PHNUM:8 AT_PAGESZ: 4096 AT_FLAGS:0x0 AT_ENTRY:0x4003e0 AT_BASE: 0x80050 argc = 1 argv[0] = ./test > LD_SHOW_AUXV=all ./test_with_long_filename $ LD_SHOW_AUXV=all .//test Segmentation fault (core dumped) $ ./test Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...] You have invoked `ld.so', the helper program for shared library executables. [...] $ .test Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...] You have invoked `ld.so', the helper program for shared library executables. [...] # note, "gdb ./test" produced same result as "gdb .test" $ LD_SHOW_AUXV=all gdb ./test [...] (gdb) r Starting program: /tmp/test Program received signal SIGSEGV, Segmentation fault. 0x0008006843d0 in strchr () from /gnu/lib/libc.so.0.1 (gdb) bt #0 0x0008006843d0 in strchr () from /gnu/lib/libc.so.0.1 #1 0x000800684f81 in *__GI_strrchr (s=Variable "s" is not available. ) at ../sysdeps/generic/strrchr.c:37 #2 0x0008006cedfb in __init_misc (argc=Variable "argc" is not available. ) at init-misc.c:34 #3 0x000800634eb9 in init (argc=0, argv=0x7fffe7f0, envp=0x7fffe7f8) at ../sysdeps/unix/bsd/bsd4.4/kfreebsd/init-first.c:83 #4 0x00080050ad6b in call_init (l=0x800517338, argc=0, argv=0x7fffe7f0, env=0x7fffe7f8) at dl-init.c:70 #5 0x00080050aeaf in _dl_init (main_map=0x8006179e8, argc=0, argv=0x7fffe7f0, env=0x7fffe7f8) at dl-init.c:142 #6 0x000800500cdb in _dl_start_user () at rtld.c:579 #7 0x000800500ca8 in _start () at rtld.c:579 -- Robert Millan -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: segfaults on amd64
Hello Robert, just guess, could you please test attached file instead of standard sysdeps/x86_64/elf/start.S ? Thanks Petr /* Startup code compliant to the ELF x86-64 ABI. Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger <[EMAIL PROTECTED]>, 2001. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. In addition to the permissions in the GNU Lesser General Public License, the Free Software Foundation gives you unlimited permission to link the compiled version of this file with other programs, and to distribute those programs without any restriction coming from the use of this file. (The GNU Lesser General Public License restrictions do apply in other respects; for example, they cover modification of the file, and distribution when not linked into another program.) Note that people who make modified versions of this file are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ /* This is the canonical entry point, usually the first thing in the text segment. The SVR4/i386 ABI (pages 3-31, 3-32) says that when the entry point runs, most registers' values are unspecified, except for: %rdx Contains a function pointer to be registered with `atexit'. This is how the dynamic linker arranges to have DT_FINI functions called for shared libraries that have been loaded before this code runs. %rsp The stack contains the arguments and environment: 0(%rsp) argc 8(%rsp) argv[0] ... (8*argc)(%rsp) NULL (8*(argc+1))(%rsp) envp[0] ... NULL */ #include "bp-sym.h" .text .globl _start .type _start,@function _start: /* Clear the frame pointer. The ABI suggests this be done, to mark the outermost frame obviously. */ xorq %rbp, %rbp /* Extract the arguments as encoded on the stack and set up the arguments for __libc_start_main (int (*main) (int, char **, char **), int argc, char *argv, void (*init) (void), void (*fini) (void), void (*rtld_fini) (void), void *stack_end). The arguments are passed via registers and on the stack: main: %rdi argc: %rsi argv: %rdx init: %rcx fini: %r8 rtld_fini: %r9 stack_end: stack. */ movq %rdx, %r9 /* Address of the shared library termination function. */ movq %rdi, %rsp popq %rsi /* Pop the argument count. */ movq %rsp, %rdx /* argv starts just at the current stack top. */ /* Align the stack to a 16 byte boundary to follow the ABI. */ andq $~15, %rsp pushq %rax /* Push garbage because we push 8 more bytes. */ /* Provide the highest stack address to the user code (for stacks which grow downwards). */ pushq %rsp #ifdef SHARED /* Pass address of our own entry points to .fini and .init. */ movq [EMAIL PROTECTED](%rip), %r8 movq [EMAIL PROTECTED](%rip), %rcx movq BP_SYM (main)@GOTPCREL(%rip), %rdi /* Call the user's main function, and exit with its value. But let the libc call main.*/ call BP_SYM (__libc_start_main)@PLT #else /* Pass address of our own entry points to .fini and .init. */ movq $__libc_csu_fini, %r8 movq $__libc_csu_init, %rcx movq $BP_SYM (main), %rdi /* Call the user's main function, and exit with its value. But let the libc call main.*/ call BP_SYM (__libc_start_main)
glibc on kfreebsd-amd64 (was: Re: segfaults on amd64, one more update)
On Sun, Feb 26, 2006 at 07:59:21PM +0100, Petr Salinger wrote: > Hello Robert, > > one more update, please could you test > with sysdeps/x86_64/elf/start.S from previous mail > and enclosed sysdeps/x86_64/dl-machine.h > > iff it works, I will write something better, > but for test this should be sufficient. Works!! More complex programs like grep work fine, too. I'm running glibc testsuite now, and will run coreutils testsuite within a few minutes. I might be able to build sane .debs tomorrow. Guillem, could you enable kfreebsd-amd64 in gnuab? -- Robert Millan -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
r1251 - in trunk/glibc-2.3-head/patches: . hacks
Author: rmh Date: 2006-02-26 21:58:23 + (Sun, 26 Feb 2006) New Revision: 1251 Added: trunk/glibc-2.3-head/patches/hacks/ trunk/glibc-2.3-head/patches/hacks/amd64_segfault.diff Log: Add amd64_segfault.diff (patch from Petr). Added: trunk/glibc-2.3-head/patches/hacks/amd64_segfault.diff === --- trunk/glibc-2.3-head/patches/hacks/amd64_segfault.diff 2006-02-25 14:44:01 UTC (rev 1250) +++ trunk/glibc-2.3-head/patches/hacks/amd64_segfault.diff 2006-02-26 21:58:23 UTC (rev 1251) @@ -0,0 +1,35 @@ + +Author: petr +Status: do not submit!! petr said he would make a proper version + +diff -ur glibc-2.3.6.old/sysdeps/x86_64/dl-machine.h glibc-2.3.6/sysdeps/x86_64/dl-machine.h +--- glibc-2.3.6.old/sysdeps/x86_64/dl-machine.hWed Feb 16 10:58:02 2005 glibc-2.3.6/sysdeps/x86_64/dl-machine.hSun Feb 26 20:21:19 2006 +@@ -261,7 +261,7 @@ + .globl _start\n\ + .globl _dl_start_user\n\ + _start:\n\ +- movq %rsp, %rdi\n\ ++ movq %rdi, %rsp\n\ + call _dl_start\n\ + _dl_start_user:\n\ + # Save the user entry point address in %r12.\n\ +@@ -298,6 +298,7 @@ + leaq _dl_fini(%rip), %rdx\n\ + # And make sure %rsp points to argc stored on the stack.\n\ + movq %r13, %rsp\n\ ++ movq %rsp, %rdi\n\ + # Jump to the user's entry point.\n\ + jmp *%r12\n\ + .previous\n\ +diff -ur glibc-2.3.6.old/sysdeps/x86_64/elf/start.S glibc-2.3.6/sysdeps/x86_64/elf/start.S +--- glibc-2.3.6.old/sysdeps/x86_64/elf/start.S Sun Feb 26 20:16:37 2006 glibc-2.3.6/sysdeps/x86_64/elf/start.S Sun Feb 26 20:20:48 2006 +@@ -80,6 +80,7 @@ + + movq %rdx, %r9 /* Address of the shared library termination + function. */ ++ movq %rdi, %rsp + popq %rsi /* Pop the argument count. */ + movq %rsp, %rdx /* argv starts just at the current stack top. */ + /* Align the stack to a 16 byte boundary to follow the ABI. */ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: segfaults on amd64
On Sun, Feb 26, 2006 at 03:12:03PM +0100, Petr Salinger wrote: > Hello Robert, > > just guess, could you please test attached file instead of standard > sysdeps/x86_64/elf/start.S ? Segfault again, also dependant on argv[0] length. This time the backtrace is a bit different though, see attached logs. -- Robert Millan [GDB will not be able to debug user-mode threads: /gnu/lib/libthread_db.so: Undefined symbol "ps_pdwrite"] GNU gdb 6.1.1 [FreeBSD] Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "amd64-marcel-freebsd"... (gdb) r Starting program: /tmp/test Program received signal SIGSEGV, Segmentation fault. fixup (l=0x8006179e8, reloc_offset=Variable "reloc_offset" is not available. ) at dl-machine.h:347 347 dl-machine.h: No such file or directory. in dl-machine.h (gdb) bt #0 fixup (l=0x8006179e8, reloc_offset=Variable "reloc_offset" is not available. ) at dl-machine.h:347 #1 0x00080050a602 in _dl_runtime_resolve () at dl-runtime.c:136 #2 0x0040040d in _start () at ../sysdeps/x86_64/elf/start.S:114 #3 0x0008006179e8 in _r_debug () #4 0x0008006179c0 in rtld_errno () from /lib64/ld-kfreebsd-x86-64.so.1 #5 0x00080051462d in dots.6572 () from /lib64/ld-kfreebsd-x86-64.so.1 #6 0x00500708 in __JCR_LIST__ () #7 0x000800517348 in ?? () [...] 55829 ktrace RET ktrace 0 55829 ktrace CALL execve(0x7fffe9d7,0x7fffe808,0x7fffe818) 55829 ktrace NAMI "./test" 55829 ktrace NAMI "/lib64/ld-kfreebsd-x86-64.so.1" 55829 test RET execve 0 55829 test CALL getuid 55829 test RET getuid 1001/0x3e9 55829 test CALL geteuid 55829 test RET geteuid 1001/0x3e9 55829 test CALL getgid 55829 test RET getgid 1001/0x3e9 55829 test CALL getegid 55829 test RET getegid 1001/0x3e9 55829 test CALL break(0x800618000) 55829 test RET break -1 errno 12 Cannot allocate memory 55829 test CALL mmap(0,0x1000,0x3,0x1002,0x,0,0) 55829 test RET mmap 5337088/0x800517000 55829 test CALL access(0x800511f50,0x4) 55829 test NAMI "/etc/ld.so.preload" 55829 test RET access -1 errno 2 No such file or directory 55829 test CALL open(0x7fffdfd0,0,0) 55829 test NAMI "/gnu/lib/tls/libc.so.0.1" 55829 test RET open -1 errno 2 No such file or directory 55829 test CALL stat(0x7fffdfd0,0x7fffdf38) 55829 test NAMI "/gnu/lib/tls" 55829 test RET stat -1 errno 2 No such file or directory 55829 test CALL open(0x7fffdfd0,0,0) 55829 test NAMI "/gnu/lib/libc.so.0.1" 55829 test RET open 3 55829 test CALL read(0x3,0x7fffe170,0x280) 55829 test GIO fd 3 read 640 bytes 0x 7f45 4c46 0201 0100 0300 3e00 0100 20d0 0100 4000 |.ELF..>. [EMAIL PROTECTED]| 0x0022 f80a 8000 4000 3800 0a00 4000 5c00 5900 0600 |[EMAIL PROTECTED]@.\.Y.| 0x0044 0500 4000 4000 4000 3002 |[EMAIL PROTECTED]@[EMAIL PROTECTED]| 0x0066 3002 0800 0300 0400 400e 1000 |[EMAIL PROTECTED]| 0x0088 400e 1000 400e 1000 2100 2100 2000 |@[EMAIL PROTECTED] .| 0x00aa 0100 0500 |..| 0x00cc 808a 1100 808a 1100 1000 0100 0600 |..| 0x00ee d88b 1100 d88b 2100 d88b 2100 0852 |!...!..R..| 0x0110 1094 1000 0200 0600 60ba 1100 60ba |`...`.| 0x0132 2100 60ba 2100 d001 d001 0800 |!.`.!.| 0x0154 0400 0400 7002 7002 7002 |p...p...p.| 0x0176 2000 2000 0400 0700 0400 |.. ... ...| 0x0198 d88b 1100 d88b 2100 d88b 2100 1000 5000 |..!...!.P.| 0x01ba 0800 50e5 7464 0400 640e 1000 640e 1000 |..P.tdd...d...| 0x01dc 640e 1000 544f 544f
Re: glibc on kfreebsd-amd64 (was: Re: segfaults on amd64, one more update)
On Sun, Feb 26, 2006 at 09:13:37PM +0100, Robert Millan wrote: > On Sun, Feb 26, 2006 at 07:59:21PM +0100, Petr Salinger wrote: > > one more update, please could you test > > with sysdeps/x86_64/elf/start.S from previous mail > > and enclosed sysdeps/x86_64/dl-machine.h > > > > iff it works, I will write something better, > > but for test this should be sufficient. > > Works!! > > More complex programs like grep work fine, too. I'm running glibc testsuite > now, and will run coreutils testsuite within a few minutes. Nice! > I might be able to build sane .debs tomorrow. Guillem, could you enable > kfreebsd-amd64 in gnuab? Done. regards, guillem -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: glibc on kfreebsd-amd64 (was: Re: segfaults on amd64, one more update)
On Sun, Feb 26, 2006 at 09:13:37PM +0100, Robert Millan wrote: > > Works!! > > More complex programs like grep work fine, too. I'm running glibc testsuite > now, and will run coreutils testsuite within a few minutes. I have committed the list of testsuite failures in trunk/glibc-2.3-head/AMD64. Most userland utils work fine, but it seems that make and tar segfault under certain (reproducible) conditions. Interestingly, they also make gdb crash :). I'll look further into that later. If these errors are not showstoppers, still hope to get working debs today, at least for the toolchain. -- Robert Millan -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
r1252 - trunk/glibc-2.3-head
Author: rmh Date: 2006-02-27 07:18:50 + (Mon, 27 Feb 2006) New Revision: 1252 Modified: trunk/glibc-2.3-head/AMD64 Log: Misc updates (including glibc testsuite failures). Modified: trunk/glibc-2.3-head/AMD64 === --- trunk/glibc-2.3-head/AMD64 2006-02-26 21:58:23 UTC (rev 1251) +++ trunk/glibc-2.3-head/AMD64 2006-02-27 07:18:50 UTC (rev 1252) @@ -1,5 +1,51 @@ TODO: +* glibc testsuite failures: + +[csu/tst-empty.out] Error 139 +[catgets/de/libc.cat] Error 1 +[catgets/test1.cat] Error 1 +[catgets/test-gencat.out] Error 1 +[stdlib/tst-strtod.out] Error 1 +[stdlib/testmb2.out] Error 1 +[stdio-common/test-popen.out] Error 138 +[stdio-common/xbug.out] Error 138 +[stdio-common/errnobug.out] Error 138 +[stdio-common/tst-swprintf.out] Error 1 +[stdio-common/bug14.out] Error 1 +[stdio-common/tst-popen.out] Error 1 +[libio/tst-widetext.out] Error 1 +[libio/tst-ungetwc2.out] Error 1 +[libio/tst-swscanf.out] Error 1 +[libio/bug-ungetwc2.out] Error 1 +[libio/bug-rewind.o] Error 1 +[libio/bug-rewind2.o] Error 1 +[libio/bug-ungetc.o] Error 1 +[libio/bug-ftell.out] Error 1 +[dlfcn/tststatic.out] Error 139 +[dlfcn/tststatic2.out] Error 139 +[string/tst-strxfrm.out] Error 1 +[wcsmbs/tst-btowc.out] Error 1 +[wcsmbs/tst-mbrtowc.out] Error 1 +[time/tst-strptime.out] Error 1 +[time/tst-ftime_l.out] Error 1 +[posix/tst-fnmatch.out] Error 1 +[posix/tst-regexloc.out] Error 1 +[posix/tst-regex.out] Error 1 +[posix/bug-regex5.out] Error 1 +[posix/bug-regex6.out] Error 1 +[posix/bug-regex17.out] Error 1 +[posix/bug-regex18.out] Error 1 +[posix/bug-regex19.out] Error 1 +[posix/bug-regex20.out] Error 1 +[posix/bug-regex22.out] Error 1 +[posix/tst-rxspencer.out] Error 1 +[posix/tst-vfork1.out] Error 1 +[posix/tst-vfork2.out] Error 1 +[posix/tst-waitid.out] Error 1 (already known, see NOTES) +[posix/wordexp-test.out] Error 139 + + * decide ld.so location It should be unique between all (at least Debian) ports, namely not the same as on kfreebsd-i386 (/lib/ld.so.1). @@ -17,7 +63,7 @@ Ideally, we should support gcc in variants cross biarch on i386 - native on amd6 + native on amd64 biarch on amd64 * biarch capable kfreebsd-kernel-headers @@ -42,10 +88,6 @@ * prepare kernel -* archive -? ftp.gnuab.org - - * buildd machine * buildd admin @@ -53,10 +95,10 @@ * porting machine admin - - binutils: - +See web/patches/binutils_elfosabi.diff + for biarch simply add to debian/rules: ifeq ($(DEB_HOST_ARCH),kfreebsd-i386) CONFARGS += --enable-targets=x86_64-kfreebsd-gnu @@ -64,37 +106,5 @@ gcc-x.y: -insert into gcc/config/i386/kfreebsd-gnu.h something like: -*** -/* Provide a LINK_SPEC. Here we provide support for the special GCC - options -static and -shared, which allow us to link things in one - of these three modes by applying the appropriate combinations of - options at link-time. - - When the -shared link option is used a final link is not being - done. */ - -#undef LINK_SPEC -#if TARGET_64BIT_DEFAULT -#define LINK_SPEC "%{!m32:-m elf_x86_64_fbsd} %{m32:-m elf_i386_fbsd} \ - %{shared:-shared} \ - %{!shared: \ -%{!static: \ - %{rdynamic:-export-dynamic} \ - %{m32:%{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \ - %{!m32:%{!dynamic-linker:-dynamic-linker /lib/ld-kfreebsd-x86-64.so.1}}} \ -%{static:-static}}" -#else -#define LINK_SPEC "%{m64:-m elf_x86_64_fbsd} %{!m64:-m elf_i386_fbsd} \ - %{shared:-shared} \ - %{!shared: \ -%{!static: \ - %{rdynamic:-export-dynamic} \ - %{!m64:%{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \ - %{m64:%{!dynamic-linker:-dynamic-linker /lib/ld-kfreebsd-x86-64.so.1}}} \ -%{static:-static}}" -#endif - -*** - +See web/patches/gcc_amd64.diff -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]