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

Lots of memory leak fixes #60629

Merged
merged 9 commits into from
Feb 17, 2025
Merged

Lots of memory leak fixes #60629

merged 9 commits into from
Feb 17, 2025

Conversation

nyalldawson
Copy link
Collaborator

I was trying to work out why the shapefile provider test randomly fails, but found a bunch of leaks instead... 🤷

From the sip documentation:

    If state is not NULL then the location it points to is set to
    describe the state of the returned C/C++ instance and is the
    value returned by any %ConvertToTypeCode. The calling code
    must then release the value at some point to prevent a memory
    leak by calling sipReleaseType().

These methods were only calling sipReleaseType in the case that
an error occurred, which is incorrect -- it should always be
called.
getLayer can alter the container we are iterating over, which
means that key is deleted while we are still using it.

Make a copy instead to avoid.
@github-actions github-actions bot added this to the 3.42.0 milestone Feb 17, 2025
QgsWkbPtr does NOT take ownership of the data, port to QByteArray instead
Copy link

github-actions bot commented Feb 17, 2025

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 3a893ac)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 3a893ac)

@troopa81 troopa81 merged commit ffc2489 into qgis:master Feb 17, 2025
31 checks passed
@qgis-bot
Copy link
Collaborator

The backport to release-3_40 failed:

The process '/usr/bin/git' failed with exit code 1
stderr
error: could not apply a152cbecdb1... Fix numerous leaks in sip method code
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"

stdout
[backport-60629-to-release-3_40 7678fc9fe1d] Fix leak in QgsSQLStatement
 Author: Nyall Dawson <[email protected]>
 Date: Mon Feb 17 10:41:42 2025 +1000
 1 file changed, 1 insertion(+)
Auto-merging python/PyQt6/core/auto_generated/geometry/qgsbox3d.sip.in
CONFLICT (content): Merge conflict in python/PyQt6/core/auto_generated/geometry/qgsbox3d.sip.in
Auto-merging python/PyQt6/core/auto_generated/geometry/qgsgeometry.sip.in
Auto-merging python/PyQt6/core/auto_generated/geometry/qgspoint.sip.in
Auto-merging python/core/auto_generated/geometry/qgsbox3d.sip.in
CONFLICT (content): Merge conflict in python/core/auto_generated/geometry/qgsbox3d.sip.in
Auto-merging python/core/auto_generated/geometry/qgsgeometry.sip.in
Auto-merging src/core/geometry/qgsbox3d.h
CONFLICT (content): Merge conflict in src/core/geometry/qgsbox3d.h

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-release-3_40 release-3_40
# Navigate to the new working tree
cd .worktrees/backport-release-3_40
# Create a new branch
git switch --create backport-60629-to-release-3_40
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick dbad2f8da191e6b554bdf43dd6a87230d73d9662,a152cbecdb1d0d5a6a5044b9302d228c175003f0,6a7b8fde00bfa17fbecfb7e90e4503d25b47e6f7,baf2e5f7423def3fa7e8e657ed798cab19293903,5c0b7d8b78f769ea736ae79eed777643efc6fcdd,aa04760f806b4d3af68067fb33b5b3ac9d96ad4f,91c796eb0521ea0fe92b0b63dd16979860c86f2b,76c767fe1529d7454ffe90e9eb5213803ec0fa54,3a893ace979c721eca2f114386a64cca753e1105
# Push it to GitHub
git push --set-upstream origin backport-60629-to-release-3_40
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-release-3_40

Then, create a pull request where the base branch is release-3_40 and the compare/head branch is backport-60629-to-release-3_40.

@qgis-bot qgis-bot added the failed backport The automated backport attempt failed, needs a manual backport label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release-3_40 failed backport The automated backport attempt failed, needs a manual backport
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants