Skip to content
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

Possible double free in YAML dump #1839

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

herwinw
Copy link
Member

@herwinw herwinw commented Feb 26, 2024

A bit of background: I was trying to find out why some specs in the nightly runner (e.g. core/string/dump_spec.rb) appear as if they are completely skipped (0 passed, 0 failed, 0 errored). It turns out the YAML formatter can create invalid YAML due to a lack of character escaping in String#inspect. Even with the improvements of #1838 it still has a number of issues.

Given that we manually print the YAML output, the easiest thing to do was using the YAML library, but the first implementation resulted in double free errors (at least on my system).

This branch currently is a research branch to dive deeper into that issue.

@herwinw herwinw self-assigned this Feb 26, 2024
We can use this one to generate invalid YAML output:

    bin/natalie spec/core/string/dump_spec.rb -f yaml | ruby -ryaml -e 'p YAML.safe_load(ARGF)'
This results in a double free, which does not happen in GDB. Time to get
out the core dumps.

To create a core file:

    bin/natalie -c dump spec/core/string/dump_spec.rb
    ulimit -c unlimited
    ./dump -f yaml
    gdb dump core
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