Skip to content

Fix borrowable_ptr - #14914

Merged
ywwg merged 5 commits into
mixxxdj:2.6from
daschuer:borrowable_ptr
Feb 26, 2026
Merged

Fix borrowable_ptr#14914
ywwg merged 5 commits into
mixxxdj:2.6from
daschuer:borrowable_ptr

Conversation

@daschuer

@daschuer daschuer commented Jun 7, 2025

Copy link
Copy Markdown
Member

Use an immutable std::weak_ptr for creating borrowed_ptr to avoid a race condition with reset(). Also remove copy constructor, because writing the shared_ptr itself is not thread safe.

Shall fix #14828

Thanks to @Hapsa21 for pointing giving the hints in #14906

@Swiftb0y

Swiftb0y commented Jun 7, 2025

Copy link
Copy Markdown
Member

std::weak_ptr for creating borrowed_ptr to avoid a race condition with reset()

How exactly does the weak_ptr avoid the race with reset()?

@daschuer

daschuer commented Jun 8, 2025

Copy link
Copy Markdown
Member Author

We reset only the private copy, no other is reading from.
The weak pointer is only written in the constructor.

to avoid a race condition with reset(). Also remove copy
constructor, because writing the shared_ptr itself is not
thread safe.
@daschuer

daschuer commented Jun 9, 2025

Copy link
Copy Markdown
Member Author

In another branch I have tested this is our CO system and it reveals some issues. This is now in shape, with constant correctness.

Comment on lines +45 to +47
}
QThread::usleep(1);
for (int k = 0; k < 2; ++k) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why the second loop and the sleep?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was not able to reproduce the task switch, which causes the test failure. This sleep forces it. I will add a comment.

@github-actions

Copy link
Copy Markdown

This PR is marked as stale because it has been open 90 days with no activity.

@github-actions github-actions Bot added the stale Stale issues that haven't been updated for a long time. label Nov 22, 2025
@JoergAtGithub JoergAtGithub removed the stale Stale issues that haven't been updated for a long time. label Nov 22, 2025
@ywwg

ywwg commented Feb 17, 2026

Copy link
Copy Markdown
Member

if you move this to a branch inside mixxxdj then I can have copilot do a review, which is often useful (especially on complex code that few really understand)

@daschuer

Copy link
Copy Markdown
Member Author

Done

@ywwg

ywwg commented Feb 18, 2026

Copy link
Copy Markdown
Member

hm it's still showing up as coming from daschuer:borrowable_ptr, I'm not sure if it's possible to edit this PR without creating a new one

@daschuer daschuer mentioned this pull request Feb 18, 2026
@daschuer

Copy link
Copy Markdown
Member Author

Review comment from #16005 are done.

@ywwg ywwg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is looking good -- I had one more question on the other PR thread just to clarify: #16005 (comment)

@ywwg

ywwg commented Feb 24, 2026

Copy link
Copy Markdown
Member

one last question about the commented-out unlock

@daschuer

Copy link
Copy Markdown
Member Author

Done

@ywwg

ywwg commented Feb 25, 2026

Copy link
Copy Markdown
Member

let me know if you want to make any last tweaks before merge

@daschuer

Copy link
Copy Markdown
Member Author

This is ready to merge

@ywwg
ywwg merged commit b028abe into mixxxdj:2.6 Feb 26, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants