-
Notifications
You must be signed in to change notification settings - Fork 12.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
Dynamic linking suppresses stackeroverflow detection #110810
Comments
An easier way to reproduce: compile #[allow(unconditional_recursion)]
fn bar() {
bar()
}
#[no_mangle]
pub extern "C" fn foo() {
bar()
} with crate-type = ["cdylib"] and try to actually call this function: void foo(void);
int main(void) {
foo();
} It seems like dynamic linking suppresses stack overflow detection. I’m not sure that’s a bug. |
Changing the labels and title according to the investigation from @GoldsteinE |
@Nilstrieb hmm, did you mean to label this as T-libs? Anything to do with guard pages seems like it should be T-compiler to me. |
Ah, is this actually missing guard pages? Fair then, I though it was hitting them and just missing the stackerflow detection, which is implemented in the library. |
I'll slap A-runtime on it to be safe 😄 |
For dylibs we skip the runtime initialization of libstd, which is responsible for setting up the stack overflow handler (and adding a guard page on platforms that don't have this already. Linux and OpenBSD add one by default). Doing this in a global constructor would be bad as it could overwrite an existing SIGSEGV handler in case of dlopen. In this case however rustc actually overwrite the SIGSEGV handler of rustc's copy of libstd to show backtraces if LLVM crashes. It is this SIGSEGV handler that is shown here. If rustc didn't override the SIGSEGV handler, rustc's copy of libstd would have printed the stack overflow message. |
Code
The crate type is
[lib] proc_macro = true
. There are no explicit dependencies.lib.rs code is:
Invoking the macro in another crate leads to the following
signal: 11, SIGSEGV: invalid memory reference
error when compiling that other crate.Meta
Reproduced on Stable:
And nightly:
Error output
Backtrace
The text was updated successfully, but these errors were encountered: