Skip to content

Stack overflow when validating recursive structures #248

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

Open
cryptix opened this issue Mar 12, 2025 · 0 comments
Open

Stack overflow when validating recursive structures #248

cryptix opened this issue Mar 12, 2025 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@cryptix
Copy link

cryptix commented Mar 12, 2025

Hi,

we are trying to validate conformance of some tree structure. Sadly we are seeing a stack overflow, even for simple cases like this:

;; example.cddl

; Root object
Tree = {
  root: Node
}

; Simple tree structure
Node = [
  value: text,
  children: [* Node]  ; Here's the recursion - Node contains Nodes
]

Here is some example data:

$ python
>>> import cbor2
>>> d = {
...   "root": ["value", [["child1", []], ["child2", []]]]
... }
>>> d
{'root': ['value', [['child1', []], ['child2', []]]]}
>>> cbor2.dumps(d).hex()
'a164726f6f74826576616c75658282666368696c64318082666368696c643280'

Running this through validate crashes the tool:

echo a164726f6f74826576616c75658282666368696c64318082666368696c643280 | xxd -r -p | cddl validate --stdin --cddl example.cddl
[INFO] Root type for validation: Tree

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
Aborted (core dumped)

Is this to be expected or am I just holding it wrong somehow?

Thanks

@anweiss anweiss self-assigned this Mar 25, 2025
@anweiss anweiss added the bug Something isn't working label Mar 25, 2025
@anweiss anweiss added this to the v1.0.0 milestone Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants