Skip to content

Guard rfl::yaml::Reader against recursive aliases and out-of-bounds literal marks - #72

Open
clockblocker wants to merge 1 commit into
mainfrom
yaml-recursive-alias-guard
Open

clockblocker wants to merge 1 commit into
mainfrom
yaml-recursive-alias-guard

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

AI-authored below this line.

Upstream PR: munich-data-engineering/reflect-cpp#801

Problem

Cyclic YAML anchors (&self / *self) caused stack-overflow crashes in rfl::yaml::Reader.

Separately, literal-block detection indexed yaml_str_[node.Mark().pos] without bounds checks, reading out-of-bounds on programmatic nodes (pos == -1).

# Before: stack-overflow crash on cyclic alias
# After:  returns rfl::Error ("Recursive YAML alias detected.") at path ["child"]
&self
name: loop
child: *self

Summary

  • Tracks active ancestor nodes with a thread-local RAII guard, rejecting direct and mutual cycles while allowing non-cyclic DAG aliases and keeping const Reader thread-safe.
  • Bounds-checks Mark().pos before indexing into the YAML source buffer.

Consumer Impact

Consumer Location Pain point solved
openmoq/moqx LoaderTest.cpp#L605-L625 Guards against self-referencing YAML aliases (YamlDuplicateKeys.cpp#L23-L24).
FANUC-CORPORATION/fanuc_driver gpio_config.cpp#L18 Parses robot YAML configs via rfl::yaml::load.
For Agents

@clockblocker
clockblocker force-pushed the yaml-recursive-alias-guard branch 2 times, most recently from 1996644 to 71fdf3e Compare December 1, 2026 06:05
…iteral marks

Track ancestor YAML nodes via a thread-local RAII guard (ActiveNodeGuard in
src/rfl/yaml/Reader.cpp) across read_object and read_array so cyclic YAML
aliases return an rfl::Error instead of overflowing the stack, while keeping
const Reader instances thread-safe and allowing non-cyclic (DAG) alias reuse.

Also bounds-check YAML::Mark::pos before indexing yaml_str_ when trimming
trailing newlines on literal block scalars.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant