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

Fix crash when removing breakpoints from DAP, and multiple fixes #104523

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rsubtil
Copy link
Contributor

@rsubtil rsubtil commented Mar 23, 2025

Closes #104078
Closes #95998 (very very likely)

This fixes an use-after-free bug that would occur when deleting a breakpoint, because the breakpoint list was being iterated and deleted at the same time. This step is divided into two to prevent this issue. I've tested DAP usage in general under ASAN, and didn't find any other similar problems.

This also includes other fixes for bugs that I identified while fixing it, and since I haven't found cases reporting similar behavior, I decided to bundle it all here as well:

  • Adding breakpoints did not check if they existed previously. This resulted in duplicated information that grows exponentially (e.g adding breakpoints on lines 1 2 3, due to the DAP workflow, would result in 3 requests, and end up with breakpoints 1, 1 2, 1 2 3).
  • Some cases that used List unnecessarily when Vector is more efficient and straighforward
  • Separate DAP::Stackframe info from scope IDs mapping, not only to simplify the code, but to avoid using the map inneficiently (it was used to search for keys and values)
  • Update checksums of DAP::Source whenever breakpoints are requested, as it's likely the file may have changed in this case
    • Following on that, DAP::Sources are also now cached and shared between different objects.

@rsubtil rsubtil requested a review from a team as a code owner March 23, 2025 18:07
@AThousandShips AThousandShips added bug topic:editor cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release labels Mar 23, 2025
@AThousandShips AThousandShips added this to the 4.5 milestone Mar 23, 2025
ProfessorOctopus added a commit to ProfessorOctopus/godot that referenced this pull request Mar 26, 2025
Fix crash when removing breakpoints from DAP, and multiple fixes godotengine#104523 by rsubtil
TextureEditors: Compile shader/material only once godotengine#104488 by arkology
Renderer: Warn when images need to be converted due to their formats being unsupported by hardware godotengine#104480 by BlueCube3310
Optimize startup times by using ubrk_clone instead of ubrk_open. godotengine#104455 by Ivorforce
Pause audio when game is paused godotengine#104420 by pafuent
Optimize reverb by removing stray volatile from the undenormalize function signature. godotengine#104239 by Ivorforce
Add Memory::alloc_static_zeroed to allocate memory that's filled with zeroes. godotengine#104124 by Ivorforce
Switch occlusion culling to be based on depth instead of Euclidean distance godotengine#103798 by Rudolph-B
Optimize Object::cast_to by assuming no virtual and multiple inheritance, gaining 7x throughput over dynamic_cast. godotengine#103708 Ivorforce
Optimize Projection::determinant() godotengine#103671 by MaxIsJoe
Reuse Sprite3D meshes across nodes when possible. godotengine#103312 by chocola-mint
Reduce frequency of save_default_environment() calls godotengine#102991 by KoBeWi
Optimize GDScriptLambdaCallable by skipping the unnecessary ObjectDB lookup for script. godotengine#102930 by Ivorforce
@van800
Copy link
Contributor

van800 commented Mar 31, 2025

@rsubtil Thank you for the fixes, I have tried from this branch and breakpoints are fine, however I was never able to evaluate EncodedObjectAsID

Image

@van800
Copy link
Contributor

van800 commented Mar 31, 2025

Did couple more tests. Seems like object evaluation problem is unrelated to your changes.
It works in 4.4/4.4.1, but is broken in 4.5_dev1 and master.
#104834, #104445

@rsubtil
Copy link
Contributor Author

rsubtil commented Mar 31, 2025

Can confirm as well, and it is not related to these changes. I'll join the discussion on #104834 to find out more.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Looks good to me. Needs rebase.

@rsubtil
Copy link
Contributor Author

rsubtil commented Mar 31, 2025

Looks good to me. Needs rebase.

Fixed, thanks for the heads-up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release topic:editor
Projects
None yet
4 participants