Closed Jasha10 closed 3 years ago
I think Python segfaulting is strictly a bug in the Python interpreter. Trying to detect cycles is very complicated and is a losing game, there are too ways for cycles to manifest.
This bug specifically should be easy to fix, the interpolation ${}
seems illegal to begin with so we can fail early on it.
iirc, #602 was preventing an infinite loop which is worse than a recursion error and was relatively easy to prevent. In general, I am not opposed to improvements like that but I feel that cycle detection only to issue an alternative error to Stack Overflow is not worth the investment.
Edited the comment ^
Ok, sounds good.
I'll close this issue and open another one r.e. failfast for the ${}
interpolation.
@odelalleau, happy to hear your thoughts on this.
@odelalleau, happy to hear your thoughts on this.
When working on #602 I initially wanted to make it more generic so as to catch more infinite recursion situations, however it proved to be quite tricky because there can be long chains of function calls causing recursions to the parent, and trying to keep track of the visited nodes along the way seemed too painful to be worth it.
But if someone can come up with a simple and efficient solution, then great, go ahead!
Another difficulty is that when using dunder methods like __eq__
you can't change the function signature to pass additional state.
This makes it impossible to pass state cleanly, and would require some kind of per object / per thread state.
Question: If an operation on cyclic configs can cause the program to crash, how should we handle this? We could:
Background / Motivation:
_get_full_key
is called. An error is raised when a cycle is detected, thus preventing runaway states / recursion errors. Internally, a pythonset()
is used to track the id's of objects that have "already been seen".Recently I discovered that calling
x = OmegaConf.create({'x': '${}'}); x == x
causes the python process to crash on my computer:Duping the core and exiting the python process is a very serious error state. This makes me think that we should consider adding more cycle detection / prevention logic when such bugs appear, so that these become recoverable errors.