On Tue, Sep 03, 2019 at 11:49:05PM -0400, George Koehler wrote:
> On Tue, 27 Aug 2019 21:04:00 +0200
> Otto Moerbeek <otto@drijf.net> wrote:
>
> > A first shot did not work here, so if you can take a closer look please
> > do. In the meantime I'll try to do so as well after reading up on the ABI.
>
> I made my own attempt to fix the *ppc32_sysv_elf* assembly code in
> lang/boost, but I made some mistake. I believe that I set the stack
> pointer %r1 outside MAP_STACK memory. This causes the machine to
> freeze, as the macppc kernel gets stuck in an infinite loop, repeatedly
> printing a message like
>
> [jump]57834/195711 sp=9421ffc0 inside ffbee000-fffee000: not MAP_STACK
>
> where "jump" is the name of the executable. "jump" is one of the
> programs from WRKSRC/libs/context/example
>
> To get the kernel messages to appear, I needed to rcctl stop xenodm,
> so xconsole doesn't grab the messages. Then I ran the executable from
> the boot console ttyC0 (Ctrl-Meta-F1).
>
> I don't need boost to reproduce this kernel problem; it is enough to
> build a program that sets a bad stack pointer, like
>
> $ cat crash.c
> #include <stdlib.h>
> int
> main(void) {
> malloc(16384);
> __asm__("addi %r1, %r3, 16368");
> exit(0);
> }
> $ gcc -o crash crash.c
> $ ./crash
>
> The stuck kernel responds to nothing -- it doesn't answer ping(8) --
> so my only way out is to force off the power, by holding the power
> button of my PowerBook G4. I need to work around this kernel problem;
> I might upgrade to a newer snapshot (my kernel is from Aug 26), report
> a bug, or try to build a kernel without the MAP_STACK check.
The kernel is supposed to abort programs that have a stack pointer
not pointing to a MAP_STACK flagged reagion. The repeating is indeed a
bug.
Pleaase post your test program on bugs. This need to be fixed to be
able to do debug the boost problem further.
-Otto
>
> The rest of this email is the *broken* diff to devel/boost. It
> includes your fixes, plus my assembly changes.
>
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/devel/boost/Makefile,v
> retrieving revision 1.89
> diff -u -p -r1.89 Makefile
> --- Makefile 9 Aug 2019 11:25:29 -0000 1.89
> +++ Makefile 4 Sep 2019 02:39:07 -0000
> @@ -17,7 +17,7 @@ EXTRACT_SUFX= .tar.bz2
> FIX_EXTRACT_PERMISSIONS = Yes
>
> REVISION-main= 6
> -REVISION-md= 1
> +REVISION-md= 2
>
> SO_VERSION= 9.0
> BOOST_LIBS= boost_atomic-mt \
> Index: patches/patch-libs_context_build_Jamfile_v2
> ===================================================================
> RCS file: patches/patch-libs_context_build_Jamfile_v2
> diff -N patches/patch-libs_context_build_Jamfile_v2
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-libs_context_build_Jamfile_v2 4 Sep 2019 02:39:07 -0000
> @@ -0,0 +1,16 @@
> +$OpenBSD$
> +
> +The second "clang" should be "gcc".
> +
> +Index: libs/context/build/Jamfile.v2
> +--- libs/context/build/Jamfile.v2.orig
> ++++ libs/context/build/Jamfile.v2
> +@@ -326,7 +326,7 @@ alias asm_sources
> + <address-model>32
> + <architecture>power
> + <binary-format>elf
> +- <toolset>clang
> ++ <toolset>gcc
> + ;
> +
> + alias asm_sources
> Index: patches/patch-libs_context_src_asm_jump_ppc32_sysv_elf_gas_S
> ===================================================================
> RCS file: patches/patch-libs_context_src_asm_jump_ppc32_sysv_elf_gas_S
> diff -N patches/patch-libs_context_src_asm_jump_ppc32_sysv_elf_gas_S
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-libs_context_src_asm_jump_ppc32_sysv_elf_gas_S 4 Sep 2019 02:39:07 -0000
> @@ -0,0 +1,66 @@
> +$OpenBSD$
> +
> +ELF systems other than Linux use a different convention to return a
> +small struct like transfer_t.
> +
> +Index: libs/context/src/asm/jump_ppc32_sysv_elf_gas.S
> +--- libs/context/src/asm/jump_ppc32_sysv_elf_gas.S.orig
> ++++ libs/context/src/asm/jump_ppc32_sysv_elf_gas.S
> +@@ -78,6 +78,9 @@
> + .align 2
> + .type jump_fcontext,@function
> + jump_fcontext:
> ++ # Linux: jump_fcontext( hidden transfer_t * %r3, %r4, %r5)
> ++ # Other: transfer_t %r3:%r4 = jump_fcontext( %r3, %r4)
> ++
> + # reserve space on stack
> + subi %r1, %r1, 244
> +
> +@@ -121,7 +124,9 @@ jump_fcontext:
> + stw %r29, 216(%r1) # save R29
> + stw %r30, 220(%r1) # save R30
> + stw %r31, 224(%r1) # save R31
> ++#ifdef __Linux__
> + stw %r3, 228(%r1) # save hidden
> ++
No comments:
Post a Comment