-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stdlib: fix re:replace on LTO builds #2194
Conversation
Please remove the now redundant macro definition in otp/erts/emulator/beam/beam_emu.c Lines 376 to 385 in 2367dc1
|
Good point! Removed. |
Thanks for the PR! We've made a few attempts in the past and found that this stack check is not the only thing that goes wrong at runtime. While we think our last one got pretty far we had to put it on the shelf as other more important things got in the way. We'd really appreciate help in this area and it would be great if someone could pick up where we left off. If you don't feel you have the time for that we'd still welcome your PR as it is. The only changes I'd like to see are that the |
Fabio Coatti reported elixir build failure in https://bugs.gentoo.org/681778. The minimal reproducer looks like that (from otp git tree): $ ./configure CFLAGS='-O2 -flto' LDFLAGS='-O2 -flto=8' $ make $ ERL_TOP=$PWD \ PATH=$ERL_TOP/bin:$PATH \ \ bin/erl \ \ -noshell -eval 're:replace("a","b","c",[{return,list}]).' \ -s erlang halt {"init terminating in do_boot",{badarg,[{re,replace,["a","b","c",[{return,list}]], [{file,"re.erl"},{line,362}]}, {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,680}]}, {init,start_it,1,[]}, {init,start_em,1,[]}, {init,do_boot,3,[]}]}} init terminating in do_boot ({badarg,[{re,replace,[[_],[_],[_],[_]],[{_},{_}]}, {erl_eval,do_apply,6,[{_},{_}]},{init,start_it,1,[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}) Crash dump is being written to: erl_crash.dump...done The failure happens in libpcre2 where stack overflow is mis-identified at function entry of erts_pcre_compile2() compile_regex() if (PUBL(stack_guard) != NULL && PUBL(stack_guard)()) { *errorcodeptr= ERR85; return FALSE; } The stack "overflow" detection happens in thr_wrapper() ethr_set_stacklimit__() because the stack usage code relies on the fact that ethr_set_stacklimit__() and similar functions don't get inlined into callers for stack growth measurement. Before the change inlining avoidance was achieved by putting functions into standalone translation units. LTO makes this technique inefficient. The change marks functions explicitly as __attribute__((__noinline__)) on gcc. Reported-by: Fabio Coatti Bug: https://bugs.gentoo.org/681778 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Looks like the changes at https://github.com/garazdawi/otp/commits/lukas/erts/lto-compile handle a few things:
I'll try to send a separate pull request for I'm not sure about
Renamed to |
I think there's some kind of fix for
A separate commit in this PR is fine.
We want to enable it by default once we believe it's stable, and for that we need the configure check and a flag to explicitly disable it, so we may as well add it now.
Great! |
Merged to |
Fabio Coatti reported elixir build failure in https://bugs.gentoo.org/681778.
The minimal reproducer looks like that (from otp git tree):
The failure happens in libpcre2 where stack overflow is mis-identified
at function entry of
The stack "overflow" detection happens in
because the stack usage code relies on the fact that ethr_set_stacklimit__()
and similar functions don't get inlined into callers for stack growth
measurement.
Before the change inlining avoidance was achieved by putting functions
into standalone translation units. LTO makes this technique inefficient.
The change marks functions explicitly as attribute((noinline)) on gcc.
Reported-by: Fabio Coatti
Bug: https://bugs.gentoo.org/681778