Stream: wasmtime

Topic: tls + drop + eprinln?


view this post on Zulip Dan Gohman (Mar 12 2020 at 18:20):

Is it a bug in rust that it lets me call eprintln in the drop of a thread_local object, but it crashes at runtime?

view this post on Zulip Dan Gohman (Mar 12 2020 at 18:20):

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f149db03011ee75509935043af8cb3db

view this post on Zulip Dan Gohman (Mar 12 2020 at 18:21):

@Alex Crichton ^ -- working on porting my sigaltstack code from C++ to Rust and hitting this error

view this post on Zulip Alex Crichton (Mar 12 2020 at 18:23):

@Dan Gohman its definitely dubious yeah, although not necessarily a bug

view this post on Zulip Alex Crichton (Mar 12 2020 at 18:24):

Dtors in tls run in an extremely limited context

view this post on Zulip Alex Crichton (Mar 12 2020 at 18:24):

But we probably should panic in linstd

view this post on Zulip Alex Crichton (Mar 12 2020 at 18:31):

hm no this is definitely a bug

view this post on Zulip Alex Crichton (Mar 12 2020 at 18:31):

I'll dig in

view this post on Zulip Dan Gohman (Mar 12 2020 at 18:40):

It looks like it definitely is the eprintln, which I was only using for debugging, so I have a workaround, which is to not use eprintln :-}

view this post on Zulip Alex Crichton (Mar 12 2020 at 19:01):

@Dan Gohman https://github.com/rust-lang/rust/pull/69955

This commit fixes an issue where if eprintln! is used in a TLS destructor it can accidentally cause the process to abort. TLS destructors are executed after main returns on the main thread, and at ...

Last updated: Dec 23 2024 at 13:07 UTC