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

Crash when parsing malformed XML after rxkb_context_parse() due to error handler not being reset #529

Closed
sbstnk opened this issue Oct 12, 2024 · 1 comment · Fixed by #530
Labels
bug Indicates an unexpected problem or unintended behavior registry Indicates a need for improvements or additions to Registry
Milestone

Comments

@sbstnk
Copy link
Contributor

sbstnk commented Oct 12, 2024

We got a report of gnome-shell crashing when libgweather is trying to parse malformed XML after gnome-shell has previously called (via gnome-desktop) something like:

rxkb_context_new();
rxkb_context_parse();
rxkb_context_unref();

rxkb_context_parse() calls xmlSetGenericErrorFunc() via parse() to set the global libxml2 error handler to its xml_error_func(), which depends on a valid rxkb_context. The context however is no longer valid after rxkb_context_unref(), while the error handler is still pointing to xml_error_func() . This then results in a crash whenever something causes libxml2 to trigger an error afterwards, such as libgweather in the gnome-shell report.

parse() should restore the default error handler after it is done parsing.

sbstnk added a commit to sbstnk/libxkbcommon that referenced this issue Oct 12, 2024
Leaving the custom error handler could have resulted in a crash after
the context has been freed.

Closes: xkbcommon#529
wismill pushed a commit to sbstnk/libxkbcommon that referenced this issue Oct 13, 2024
Leaving the custom error handler could have resulted in a crash after
the context has been freed.

Closes: xkbcommon#529
wismill pushed a commit that referenced this issue Oct 13, 2024
Leaving the custom error handler could have resulted in a crash after
the context has been freed.

Closes: #529
@wismill
Copy link
Member

wismill commented Oct 13, 2024

Thanks for the great debugging and the corresponding PR!

@wismill wismill added bug Indicates an unexpected problem or unintended behavior registry Indicates a need for improvements or additions to Registry labels Oct 13, 2024
@wismill wismill added this to the 1.8.0 milestone Oct 13, 2024
@wismill wismill mentioned this issue Nov 29, 2024
6 tasks
wismill pushed a commit to wismill/libxkbcommon that referenced this issue Dec 16, 2024
Leaving the custom error handler could have resulted in a crash after
the context has been freed.

Closes: xkbcommon#529
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior registry Indicates a need for improvements or additions to Registry
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants