Sergey Bugaev writes: Hello Sergey,
> On Fri, Nov 22, 2024 at 1:52 PM <jann...@gnu.org> wrote: >> Hi! > > Hi Janneke, > >> I have bisected the problem to be in sigaction.o: when linking with >> sigaction.o from Debian's libcrt.a it passes, when using Guix's >> sigaction.o it fails. Problem solved, you would say? > > I assume you mean sigreturn.o, not sigaction.o Sure, sigreturn.o, what a silly typo to make! >> Anyway, attached are the disassembled versions of Debian's and Guix's >> sigaction.o.d. Maybe some of you can spot the significant difference >> and where it might come from? > > From diff'ing the two files, one of them has > > 46: 64 44 89 24 25 80 00 mov %r12d,%fs:0x80 > > after the call to __mach_port_mod_refs (side note: it would be easier > to analyze disassembly if you passed --reloc to objdump), where %r12d > was previously > > 6: 41 89 d4 mov %edx,%r12d > > this corresponds to > > THREAD_SETMEM (THREAD_SELF, reply_port, sc_reply_port); > > in the source code. The other one doesn't do this, and seems to > clobber %edx without saving it. Oh wow, I would never have found that! We're cross-compiling this bootstrap-glibc for Guix, so we would have to check if everything was configured OK. I restarted the build and killed it after sigreturn.o was compiled, and verified that the assembly is the same. So far so good. In sysdeps/mach/hurd/x86_64/sigreturn.c, I added a redefine of THREAD_SETMEM --8<---------------cut here---------------start------------->8--- #include <hurd/msg.h> #include <stdlib.h> +#define THREAD_SETMEM foobar + /* This is run on the thread stack after restoring it, to be able to --8<---------------cut here---------------end--------------->8--- to find out which one is being used and then compiled sigreturn.c again using the (amazing) command-line that glibc creates --8<---------------cut here---------------start------------->8--- $ x86_64-pc-gnu-gcc ../sysdeps/mach/hurd/x86_64/sigreturn.c -c -std=gnu11 -fgnu89-inline -g -O2 -Wall -Wwrite-strings -Wundef -fmerge-all-constants -frounding-math -fno-stack-protector -fno-common -Wp,-U_FORTIFY_SOURCE -Wno-parentheses -Wstrict-prototypes -Wold-style-definition -fmath-errno -fPIE -fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0 -ftls-model=initial-exec -I../include -I/tmp/guix-build-glibc-cross-x86_64-pc-gnu-2.39.drv-0/build/signal -I/tmp/guix-build-glibc-cross-x86_64-pc-gnu-2.39.drv-0/build -I../sysdeps/mach/hurd/x86_64 -I../sysdeps/mach/hurd/x86 -I../sysdeps/mach/hurd/x86_64/htl -I../sysdeps/mach/hurd/htl -I../sysdeps/hurd/htl -I../sysdeps/mach/htl -I../sysdeps/htl/include -I../sysdeps/htl -I../sysdeps/pthread -I../sysdeps/x86_64/htl -I../sysdeps/x86/htl -I../sysdeps/mach/hurd -I../sysdeps/gnu -I../sysdeps/unix/bsd -I../sysdeps/unix/inet -I../sysdeps/mach/x86_64 -I../sysdeps/mach/x86 -I../sysdeps/mach/include -I../sysdeps/mach -I../sysdeps/x86_64/64 -I../sysdeps/x86_64/fpu/multiarch -I../sysdeps/x86_64/fpu -I../sysdeps/x86/fpu -I../sysdeps/x86_64/multiarch -I../sysdeps/x86_64 -I../sysdeps/x86/include -I../sysdeps/x86 -I../sysdeps/ieee754/float128 -I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/hurd/include -I../sysdeps/hurd -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/wordsize-64 -I../sysdeps/ieee754 -I../sysdeps/generic -I../hurd -I/tmp/guix-build-glibc-cross-x86_64-pc-gnu-2.39.drv-0/build/hurd/ -I../mach -I/tmp/guix-build-glibc-cross-x86_64-pc-gnu-2.39.drv-0/build/mach/ -I.. -I../libio -I. -nostdinc -isystem /gnu/store/6nfg25y6hfp8mx7j1cwq995mcm0kf6hw-gcc-cross-sans-libc-x86_64-pc-gnu-14.2.0-lib/lib/gcc/x86_64-pc-gnu/14.2.0/include -isystem /gnu/store/6nfg25y6hfp8mx7j1cwq995mcm0kf6hw-gcc-cross-sans-libc-x86_64-pc-gnu-14.2.0-lib/lib/gcc/x86_64-pc-gnu/14.2.0/include-fixed -isystem /gnu/store/axql682fcn94kkdyqgy1vv9pcx7n24zv-hurd-core-headers-cross-x86_64-pc-gnu-0.9.git20240714/include -D_LIBC_REENTRANT -include /tmp/guix-build-glibc-cross-x86_64-pc-gnu-2.39.drv-0/build/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h -DPIC -DTOP_NAMESPACE=glibc -o /tmp/guix-build-glibc-cross-x86_64-pc-gnu-2.39.drv-0/build/signal/sigreturn.o ../sysdeps/mach/hurd/x86_64/sigreturn.c:23:9: warning: "THREAD_SETMEM" redefined 23 | #define THREAD_SETMEM foobar | ^~~~~~~~~~~~~ In file included from ../sysdeps/x86/atomic-machine.h:23, from ../include/atomic.h:49, from ../mach/lowlevellock.h:24, from ../mach/lock-intern.h:23, from ../sysdeps/mach/include/lock-intern.h:2, from ../mach/spin-lock.h:22, from ../hurd/hurd/signal.h:41, from ../sysdeps/hurd/include/hurd/signal.h:9, from ../hurd/hurd/userlink.h:29, from ../hurd/hurd/port.h:25, from ../sysdeps/hurd/include/hurd/port.h:2, from ../hurd/hurd.h:41, from ../sysdeps/hurd/include/hurd.h:2, from ../sysdeps/mach/hurd/x86_64/sigreturn.c:18: ../sysdeps/mach/hurd/x86_64/tls.h:92:10: note: this is the location of the previous definition 92 | # define THREAD_SETMEM(descr, member, value) \ | ^~~~~~~~~~~~~ --8<---------------cut here---------------end--------------->8--- Hmm, that doesn't look so bad? That file is unmodified <https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/mach/hurd/x86_64/tls.h;h=3d3253963b5de04d10adf93fe52c5956108e2fd4;hb=ef321e23c20eebc6d6fb4044425c00e6df27b05f#l92> 86 # define THREAD_SELF \ 87 (*(tcbhead_t * __seg_fs *) offsetof (tcbhead_t, tcb)) 88 /* Read member of the thread descriptor directly. */ 89 # define THREAD_GETMEM(descr, member) \ 90 (*(__typeof (descr->member) __seg_fs *) offsetof (tcbhead_t, member)) 91 /* Write member of the thread descriptor directly. */ 92 # define THREAD_SETMEM(descr, member, value) \ 93 (*(__typeof (descr->member) __seg_fs *) offsetof (tcbhead_t, member) = value) ...hmm, might offsetof be the problem here? Same trick... ../sysdeps/mach/hurd/x86_64/sigreturn.c:24:9: warning: "offsetof" redefined 24 | #define offsetof barbaz | ^~~~~~~~ In file included from ../posix/sched.h:29, from ../include/sched.h:2, from ../sysdeps/htl/pthread.h:49, from ../sysdeps/htl/include/pthread.h:2, from ../include/pthread.h:1, from ../sysdeps/htl/libc-lockP.h:22, from ../sysdeps/mach/libc-lock.h:223, from ../sysdeps/htl/libc-lock.h:22, from ../sysdeps/hurd/include/hurd/port.h:5: /gnu/store/6nfg25y6hfp8mx7j1cwq995mcm0kf6hw-gcc-cross-sans-libc-x86_64-pc-gnu-14.2.0-lib/lib/gcc/x86_64-pc-gnu/14.2.0/include/stddef.h:416:9: note: this is the location of the previous definition 416 | #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) | ^~~~~~~~ eh...hmm? Last thing I tried was marking the THREAD_SETMEM calls with NOPS reply_port = THREAD_GETMEM (THREAD_SELF, reply_port); asm ("nop"); THREAD_SETMEM (THREAD_SELF, reply_port, MACH_PORT_DEAD); asm ("nop"); asm ("nop"); if (__glibc_likely (MACH_PORT_VALID (reply_port))) (void) __mach_port_mod_refs (__mach_task_self (), reply_port, MACH_PORT_RIGHT_RECEIVE, -1); asm ("nop"); asm ("nop"); asm ("nop"); THREAD_SETMEM (THREAD_SELF, reply_port, sc_reply_port); asm ("nop"); asm ("nop"); asm ("nop"); asm ("nop"); and I have attached the the objdump --reloc of this. Can you make anything of this? >> Note: on our 32bit Hurd which uses the same patch set for glibc, the >> test runs fine. For now I have disabled running check on >> findutils...but I'm afraid this test will keep coming back and fail for >> every package that uses gnulib :-( > > Well, sigreturn is arch-specific, i386-gnu and x86_64-gnu (and > aarch64-gnu) all have different implementations. Right. Greetings, Janneke
sigreturn+nop.o.d
Description: Binary data
-- Janneke Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond https://LilyPond.org Freelance IT https://www.JoyOfSource.com | Avatar® https://AvatarAcademy.com