Closed 0x6178656c closed 10 months ago
This is actually not just a problem with meta:/override
, but all the metakeys that affect cascading lookup. You can also construct cycles with e.g. meta:/fallback
or even meta:/namespace/#0
in there.
IMO we have 3 options:
ksLookup
API for this. I'd just hardcode the limit and add a int depth
argument to the internal functions.ksLookup
. However, we could add such a cycle check function to libelektra-ease
:
// checks **all** keys in `ks` for potential cycles that would cause `ksLookup` stack overflow
bool elektraCheckLookupCycles (KeySet * ks);
This function could then be called by the spec
plugin. This would ensure that keysets returned by kdbGet
are safe to use with ksLookup
and would prevent you from successfully calling kdbSet
on a keyset with cycles. If people modify the keyset or build their own and it might result in cycles, they can call the function directly too.
I would be in favour of option 3, since it is the most comprehensive solution.
Thanks for the information.
I agree that 3 sounds the most promising.
Would it make sense to implement 2 and keep 3 as a to do? The goals of 2 and 3 are a bit different. 2 prevents Elektra from crashing due to a stack overflow and 3 aims at protecting a KDB instance from containing configuration containing reference loops.
I mark this stale as it did not have any activity for one year. I'll close it in two weeks if no further activity occurs. If you want it to be alive again, ping by writing a message here or create a new issue with the remainder of this issue. Thank you for your contributions :sparkling_heart:
I closed this now because it has been inactive for more than one year. If I closed it by mistake, please do not hesitate to reopen it or create a new issue with the remainder of this issue. Thank you for your contributions :sparkling_heart:
It appears that circular links (using overrides) lead to a stack overflow.
I implemented a fix for the most simple case in #4694 but after thinking some more about this I don't think that the solution is satisfactory.
In particular, circular link chains with more than one node would not be detected (see below for an example).
Since the actual problem seems to be a stack overflow, perhaps the most straightforward and robust solution would be to introduce a limit to the recursion depth. In this case probably the API of the functions would need to be changed to make this possible.
Is the idea with a maximum recursion depth reasonable? Are there other ways to abort the circular recursion?
Steps to Reproduce the Problem
Example with two hops:
Expected Result
kdb should not crash.
Actual Result
kdb crashes.
System Information
Further Log Files and Output