-
-
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
handle infinite include loops more gracefully #33049
Comments
There's no way to detect this. Circular include is as legal as recursive functions: you get a stack overflow if you don't add a proper termination condition. It is definately not desired to guess what error the user make rather than just reporting the error. It's also not very nice to arbitrarily truncate the backtrace since it's almost guaranteed that you'll throw out exactly the useful one in some cases while not actually saving time in a lot of cases. If this is on a mac the the crash is dup of #17109. The irresponsiveness is probably just printing error (or a variant of #17109). AFAICT, the backtrace printing does finish on linux. It is indeed slower than 0.6 but that's likely simply because we are collecting much more information compared to an older version. |
@yuyichao Thanks for your comments. I'm not sure the mac issue applies, since I tested this on my linux laptop,
I get why the error happens and surely a stack overflow is bound to happen in such a case. My main concerns are:
a(x) = b(x)
b(x) = a(x)
a(1) which fails with
however, without causing the REPL or my script execution process to freeze. Afterwards I get the REPL back or the julia process terminates with an error exit code.
|
How long did you wait? It took significantly longer to print for sure ( a few seconds on my laptop) but it does finish. Without checking carefully the long time is probably due to the interpreter backtrace and the n^2 number of include filename. |
This could probably be handled more gracefully. |
@yuyichao I tested it again and indeed you are right. In all cases julia 1.2+ becomes responsive after a while. This took a bit longer on my machine (order of 2 minutes). I guess I simply was not patient enough. Thanks for looking into this nevertheless 👍. So the remaining aspect of this issue is, that the output is a bit cumbersome. This probably could be improved, but personally I would consider this fair enough in such a circumstance. Feel free to close this issue if you agree. |
This issue summarises the behaviour of julia when exposed to circular includes.
The observed behaviour varies between julia versions from segfaults, irresponsive REPL or execution to rather intractable error messages.
Even though circular includes are without a doubt a sign of bad code design, I'd find it desirable to see a more helpful error message and to avoid julia to run into a stack overflow or become irresponsive 😄.
To reproduce
a.jl
:b.jl
:Test cases
julia> include("a.jl")
was issued inside the REPL.julia a.jl
.Result summary
The behaviour changes between 1.1 and 1.2. The 1.2+ REPL behaviour is to print the error message
followed by an irresponsive REPL. When run as a script on 1.2+ the only printed output is
followed by an irresponsive julia process.
Update: In fact "irresponsive" is not correct. The REPL/process just takes long (order of 2 minutes) to respond.
The text was updated successfully, but these errors were encountered: