https://bugs.kde.org/show_bug.cgi?id=468575

--- Comment #62 from Paul Floyd <pjfl...@wanadoo.fr> ---
(In reply to Mark Wielaard from comment #60)
> (In reply to Mark Wielaard from comment #55) 
> > nestedfns fails with:
> > 
> > +Process terminating with default action of signal 11 (SIGSEGV)
> > + Bad permissions for mapped region at address 0x........
> > +   at 0x........: ???
> > +   by 0x........: call_func (nestedfns.c:14)
> > +   by 0x........: test1 (nestedfns.c:23)
> > +   by 0x........: main (nestedfns.c:37)
> > +
> > 
> > Not sure this simply means (noexecstack) nested functions simply don't work
> > on riscv?
> 
> This isn't riscv specific. It also fails on other arches.
> Seems to be caused by:
> 
> commit c5552fe28b8d89ed5a92cc736fa00d7e336a3f2c
> Author: Paul Floyd <pjfl...@wanadoo.fr>
> Date:   Fri Dec 6 21:24:50 2024 +0100
> 
>     regtest: fix a warning building none/tests/nestedfns on some platforms
> 
> diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am
> index 53a6e1f6bc95..fa0128d3a8e4 100644
> --- a/none/tests/Makefile.am
> +++ b/none/tests/Makefile.am
> @@ -335,6 +335,7 @@ endif
>  
>  if HAVE_NESTED_FUNCTIONS
>     check_PROGRAMS += nestedfns
> +   nestedfns_LDFLAGS = -Wl,-z,noexecstack
>  endif
>  
>  # This doesn't appear to be compilable on Darwin.
> 
> So this sets noexecstack for the nestedfns exec.
> But as the comment at the top of nestedfns says:
> 
> /* This is a test program from Lee Kindness which used to fail on V
>    because gcc implements the nested function mumbo jumbo using self
>    modifying code on the stack, at least on x86 and amd64.  It now
>    works transparently because by default V now generates
>    self-checking translations for translations taken from stack-like
>    segments.
> */
> 
> And indeed even on amd64-linux this program now crashes even when not run
> under valgrind:
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007fffffffd9d0 in ?? ()
> (gdb) where
> #0  0x00007fffffffd9d0 in ?? ()
> #1  0x0000000000401138 in call_func (sel=0x7fffffffd9d0) at nestedfns.c:14
> #2  0x0000000000401196 in test1 () at nestedfns.c:23
> #3  0x000000000040120b in main (argc=1, argv=0x7fffffffdb48) at
> nestedfns.c:37
> 
> And that is indeed the sel function stub on the stack...
> 
> Paul, what was the warning? And can we just accept that warning?
> Reverting this seems to make the test work again as expected.

On arm raspberrypios

/usr/bin/ld: warning: nestedfns-nestedfns.o: requires executable stack (because
the .note.GNU-stack section is executable)

but the exe runs OK

No problem on FreeBSD because this is a non-standard GCC extension that clang
doesn't accept.

I've pushed a fix that turns off the warning rather than turning off the exec
stack.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to