-
Notifications
You must be signed in to change notification settings - Fork 214
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
scheduler/job.c: unload job before freeing job history in cupsdDeletejob() #813
scheduler/job.c: unload job before freeing job history in cupsdDeletejob() #813
Conversation
…Job() With "PreserveJobHistory Off", LogLevel not set to debug (or debug2), and "LogDebugHistory 200" (the default), cupsdDeleteJob() frees the job history and then unloads the job. However, unload_job() calls cupsdLogJob() which re-creates the job history and puts "Unloading..." into it because level (debug) is greater than LogLevel (warn) and LogDebugHistory is set to 200 messages by default. Unused (and unreachable) job history is left behind, resulting in a memory leak.
To reproduce the issue:
Tested in CentOS 9 Stream (relevant code is the same). Before the patch:
After the patch:
|
Since the array `profiles` is set to use `strdup()` as a copy function, we don't have to use `strdup()` on the element which is passed as parameter of `cupsArrayAdd()` - using the `strdup()` as we used till now causes memory leak. Reproducer is the same as OpenPrinting#813 .
Since the array `profiles` is set to use `strdup()` as a copy function, we don't have to use `strdup()` on the element which is passed as parameter of `cupsArrayAdd()` - using the `strdup()` as we used till now causes memory leak. Reproducer is the same as OpenPrinting#813
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! I've verified the leak is gone.
The CI failures are the same as before - @michaelrsweet macos failure looks the same as from branch 2.4.x -
|
@zdohnal Yes, it is a problem with the macOS runners... :/ |
Since the array profiles is set to use strdup() as a copy function, we don't have to use strdup() on the element which is passed as parameter of cupsArrayAdd() - using the strdup() as we used till now causes memory leak. Reproducer is the same as #813
Since the array profiles is set to use strdup() as a copy function, we don't have to use strdup() on the element which is passed as parameter of cupsArrayAdd() - using the strdup() as we used till now causes memory leak. Reproducer is the same as #813 .
With "PreserveJobHistory Off", LogLevel not set to debug (or debug2), and "LogDebugHistory 200" (the default), cupsdDeleteJob() frees the job history and then unloads the job. However, unload_job() calls cupsdLogJob() which re-creates the job history and puts "Unloading..." into it because level (debug) is greater than LogLevel (warn) and LogDebugHistory is set to 200 messages by default. Unused (and unreachable) job history is left behind, resulting in a memory leak.
The solution seems to be to unload the job before freeing the job history.