-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Logging after stream finalization AND displaysize missing isopen check #26687
Comments
Getting the same error reported here JuliaLang/Pkg.jl#573. |
yeah, the patch for this was deleted by #28107 (and may have been closed prematurely also) |
@maleadt I think this is a perfect use for the capabilities of the logging system; the ability to switch loggers based on context is what it's all about. On the flip side, switching out the global logger from under the user isn't a great solution (though it's better than crashing!) hmm. I think the right thing here is to temporarily replace the task local logger with a low level log cache when entering "dangerous" contexts - finalizers, generated functions, certain low level runtime functions, etc. Basically any place where it's dangerous to call into arbitrary user code. Then when we exit the context, dump the cache of messages through the user's selected logger. The cache might have to be a ring buffer if we're in a context where we can't allocate, I'm not sure there's much we can do about that. This is very like to the situation I ran into when trying to standardize all logs coming from the runtime - see, for example #25413. Sometimes you're in a context where it's just not permissable to call into arbitrary julia code and the fact I was trying to do so made Jeff understandably leery of the whole project :-) |
Hah, I got a bit carried away in the analogy to other similar problems there. All the above being said, temporary logger replacement obviously can't work at exit if we never re-enter a safe context. As a simple solution I think an atexit hook is pretty acceptable. Though it would be nice for the knowledgeable user to be able to override the safe fallback logger at their option. As a more general solution, would it be possible to stage the exit process somehow? That seems hard and possibly circular. |
Regarding a staged exit, perhaps we could do two rounds of finalization? The first round cleaning up nearly everything except for a few specially rooted objects such as the streams; the second round doing the final cleanup? The second round objects would have to avoid rooting any important objects from the first round, which seems error prone... |
Closed by #34623 |
Relies on finalizers running at exit.
When printing from finalizers, we're used to see errors relating to streams being closed:
With Logging, this becomes worse as certain functions called by the stdlib on the closed streams cause Julia to segfault:
A quick fix would be to reconfigure the global logger at exit to use raw streams, preventing the segfault and making it possible to log rich messages from finalizers:
... but I'm not sure how that plays into the design of Logging (@c42f), or whether this is acceptable as an
atexit
hook.In a related vein, this is also a very useful pattern to be able to log from
@generated
functions.The text was updated successfully, but these errors were encountered: