Skip to content

Core dump occurs when parsing YAML with invalid syntax #527

@serbayozkan

Description

@serbayozkan

Hello,

In some cases where the input YAML has syntax errors, parsing causes core dumps. When this happens, as expected, it is not possible to catch it from the client code. It actually prints the error before it crashes, so it would be great to prevent the core dump and instead throw an exception or trigger an error callback to inform the client about the failure. This way, the client could know what is going on instead of getting a crashed application.

I wrote some failing examples below, so I would like to hear your feedback on this issue.

Version: 0.8.0

char yaml[] = R"(
data: [, 18 34]
)";

ryml::Tree tree = ryml::parse_in_place(yaml);

Output:
2:8: (8B): ERROR: parse error
2:8: data: [, 18 34]  (size=15)
            ^~~~~~~~  (cols 8-16)

Aborted (core dumped)
char yaml[] = R"(
data1: data1
    
	# This line includes tab.

data2: data2
)";

ryml::Tree tree = ryml::parse_in_place(yaml);

4:2: (20B): ERROR: could not find ':' colon after key
4:2:    # This line includes tab.  (size=26)
      ^~~~~~~~~~~~~~~~~~~~~~~~~  (cols 2-27)

Aborted (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions