Re: New jemalloc causes crashes - looking for ideas

Rin Okuyama <[email protected]>
Newsgroups gmane.os.netbsd.ports.arm
Message-ID <[email protected]>
Hi,

This patch works around the problem for me:

~~~
diff --git a/libexec/ld.elf_so/arch/arm/rtld_start.S 
b/libexec/ld.elf_so/arch/arm/rtld_start.S
index 667efe65b20..627f79756cb 100644
--- a/libexec/ld.elf_so/arch/arm/rtld_start.S
+++ b/libexec/ld.elf_so/arch/arm/rtld_start.S
@@ -85,11 +85,21 @@ ARM_ENTRY_NP(_rtld_bind_start)
  	ldr	r0, [lr, #-4]		/* get obj ptr from GOT[1] */
  	mov	r4, ip			/* save GOT location */

+	ands	r2, sp, #4
+	bne	2f
+
  	bl	_rtld_bind		/* Call the binder */

+1:
  	str	r0, [r4]		/* save address in GOT */
  	mov	ip, r0			/* save new address */

  	ldmia	sp!,{r0-r4,sl,fp,lr}	/* restore the stack */
  	RETr(ip)			/* jump to the new address */
+
+2:
+	sub	sp, sp, #4
+	bl	_rtld_bind
+	add	sp, sp, #4
+	b 1b
  END(_rtld_bind_start)
~~~

There seem to be two cases (calling paths?) where sp is correctly
aligned to 8-byte boundaries, and not; a dynamically-linked binary
works only if two cases are handled.

I was going to investigate further, but I've not figured yet what
happens...

Thanks,
rin

On 2025/02/03 20:00, Martin Husemann wrote:
> Hey folks,
> 
> the switch to newer jemalloc in libc recently makes evbarm (v5) userland
> fail with core dumps everywhere.
> 
> The minimum alignment (LG_QUANTUM 3, so 2^3 minimal alignement) did not
> change.
> 
> Can someone educate me how to use the external symbols from in a cross-gdb?
> I didn't get that part working, and it also seems to be unhappy with the
> core file...
> 
> [..]
> This GDB was configured as "--host=x86_64-unknown-netbsd10.99 --target=arm--netbsdelf-eabi".
> [..]
> (gdb) set sysroot /branches/hosts-current/evbearmv5/
> (gdb) file /branches/hosts-current/evbearmv5/bin/sh
> Reading symbols from /branches/hosts-current/evbearmv5/bin/sh...
> (No debugging symbols found in /branches/hosts-current/evbearmv5/bin/sh)
> (gdb) target core sh.core
> warning: BFD: warning: /tmp/sh.core has a segment extending past end of file
> [New process 11128]
> Core was generated by `sh'.
> Program terminated with signal SIGBUS, Bus error.
> #0  0xbbef4f64 in ?? ()
> (gdb) bt
> #0  0xbbef4f64 in ?? ()
> #1  0xbbef5434 in ?? ()
> (gdb) x/i 0xbbef4f64
> => 0xbbef4f64:  Cannot access memory at address 0xbbef4f64
> (gdb) info reg
> r0             0xbbcb557c          3150665084
> r1             0xbfffe384          3221218180
> r2             0xbbefe548          3153061192
> r3             0xbfffe338          3221218104
> r4             0xbbee5140          3152957760
> r5             0xbfffe33c          3221218108
> r6             0x1                 1
> r7             0xbfffe384          3221218180
> r8             0x0                 0
> r9             0x1                 1
> r10            0xbfffe338          3221218104
> r11            0xbfffe370          3221218160
> r12            0x60                96
> sp             0xbfffe2c4          0xbfffe2c4
> lr             0xbbef5434          3153024052
> pc             0xbbef4f64          0xbbef4f64
> cpsr           0xa0000010          2684354576
> 
> Martin
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.