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

rpm: Reset RPM log callback upon RpmLogGuard destruction #1870

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

m-blaha
Copy link
Member

@m-blaha m-blaha commented Nov 18, 2024

This patch addresses undefined behavior that occurs when the RPM log
callback function is invoked after the RpmLogGuard object has been
destroyed. The issue arises because rpmlogCallbackData retains a
reference to the destroyed object.

The problem manifests during the execution of the builddep plugin command:

  1. During Vars::detect_release, the RPM log callback is set via RpmLogGuard.
  2. After the release version is detected, the RpmLogGuard object is destroyed.
  3. A subsequent call to rpmSpecParse() by the builddep command may
    trigger the previously set log callback.
  4. This results in undefined behavior because the callback data still
    points to the destroyed RpmLogGuard.

By resetting the RPM log callback upon RpmLogGuard destruction, this
patch ensures safe and predictable behavior.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2326535
Resolves: #1864

This patch addresses undefined behavior that occurs when the RPM log
callback function is invoked after the RpmLogGuard object has been
destroyed. The issue arises because rpmlogCallbackData retains a
reference to the destroyed object.

The problem manifests during the execution of the builddep plugin command:

1. During Vars::detect_release, the RPM log callback is set via RpmLogGuard.
2. After the release version is detected, the RpmLogGuard object is destroyed.
3. A subsequent call to rpmSpecParse() by the builddep command may
   trigger the previously set log callback.
4. This results in undefined behavior because the callback data still
   points to the destroyed RpmLogGuard.

By resetting the RPM log callback upon RpmLogGuard destruction, this
patch ensures safe and predictable behavior.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2326535
Resolves: #1864
Copy link
Member

@jan-kolarik jan-kolarik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for a quick fix!

@jan-kolarik jan-kolarik added this pull request to the merge queue Nov 18, 2024
Merged via the queue into main with commit de1b315 Nov 18, 2024
17 of 20 checks passed
@jan-kolarik jan-kolarik deleted the mblaha/builddep-segfault branch November 18, 2024 14:14
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.

dnf5 builddep crashes in Fedora 41 container
2 participants