-
-
Notifications
You must be signed in to change notification settings - Fork 219
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
Changes to linux_reload_workaround to allow calling is_hot_reload_enabled before enable_hot_reload #1040
Changes to linux_reload_workaround to allow calling is_hot_reload_enabled before enable_hot_reload #1040
Conversation
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1040 |
i dont like changing this to allow modifying this setting after it has been set. it seems much safer to me to treat all thread locals one way or another, and not potentially have some be treated one way and others another. maybe the issue is here: gdext/godot-core/src/init/mod.rs Line 69 in 71bbfb8
it might be possible for us to change this a bit so that hot reloading is set earlier than this. maybe we can change pub trait ExtensionLibrary {
const OVERRIDE_HOT_RELOAD: Option<bool> = None;
} and then match on that value? this would guarantee that we cant panic during the execution of setting the hot reloading value, and ensure it's set before we call any of the panic handling machinery. which is where the issue seemed to come from |
I agree with lilizoey here, as mentioned in the earlier review already:
I'm wondering if anyone is using this method at all -- we could just remove it from the public API in v0.3, and use our default implemenation instead. If people complain, we can think about something. |
Alternatively, could we change:
into
I don't think it makes sense to set |
Agree with the first part, not with the second. If anyhow possible, order of initializations should be well-defined, and cause panics whenever a violation occurs. Lazy initialization for bools should be a last resort, because it can quickly lead to non-deterministic or hard-to-debug data flows. Concretely, |
…KevinThierauf/gdext-panic into linux_reload_workaround-changes
Unfortunately I don't see a clear way of doing this in a way that doesn't fail |
Currently
linux_reload_workaround.rs
storesHOT_RELOADING_ENABLED
as aOnceCell
, which only supports being accessed once. This means that the current implementation ofis_hot_reload_enabled
:Sets
HOT_RELOADING_ENABLED
for the rest of the program, and any future callsenable_hot_reload
fail. Sinceis_hot_reload_enabled
is called bythread_atexit
,thread_atexit
invocations that occur beforeenable_hot_reload
is called cause a panic.(Unrelated but similar:
disable_hot_reload
notes// If hot reloading is disabled then we may call this method multiple times.
; the current implementation will also cause a panic if called multiple times).I'm specifically encountering this issue with #1037; the
thread_local
usage leads tois_hot_reload_enabled
failing.I used some print statements in
is_hot_reload_enabled
andenable_hot_reload
to track down the itest failures in #1037:For reference,
private.rs:349:5
is:I don't know why, but for whatever reason the initialization of
ERROR_CONTEXT_STACK
, which is a thread local value, leads tothread_atexit
being called. I briefly looked through the rust stdlib source; on 1.84.1 (which I used to compile), it's called by eager.rs.In summary, it seems like using a thread local value on linux that's called before
enable_hot_reload
is called by__gdext_load_library
leads to callingis_hot_reload_enabled
, which leads toenable_hot_reload
failing.