-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
lp1744550: Fix use-after-free (and more serious issues) in GlobalTrackCache #1492
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
Merged
Merged
Changes from all commits
Commits
Show all changes
81 commits
Select commit
Hold shift + click to select a range
5d9d868
Delete obsolete initializations
uklotzde 9c13ed4
Count number of Track object instances
uklotzde cd904af
Fix memory leak: Don't use deleteLater() for temporary Track objects
uklotzde c2528d6
Minor optimizations in BaseTrackCache
uklotzde 7097985
Delete undefined function
uklotzde 8555edb
Hide private slot
uklotzde a836d45
Add regression tests for GlobalTrackCache
uklotzde 0ccdc79
lp1744550: Revive cached tracks instead of deleting
uklotzde 56d65b4
Replace Stat counters in GlobalTrackCache
uklotzde 1db98b4
Fix VS2015 build
uklotzde 20dfed2
Fix another use-after-free issue due to race condition
uklotzde 6d854c5
Delete tracks after successfully evicting them from the cache
uklotzde 59f3237
Rename callback function
uklotzde fbe891c
Destroy the GlobalTrackCache instance only once
uklotzde b8a4a98
Disable debug logging
uklotzde cf7e7e9
Merge branch '2.1' into lp1744550_globaltrackcache
uklotzde 4590b70
Minor optimizations
uklotzde 83f988e
Reduce debug log spam
uklotzde a80e84b
Disconnect all receivers instead of blocking signals before deletion
uklotzde c7fb846
Encapsulate deletion of Track objects in separate function
uklotzde 61a7673
Save modified tracks when exiting the application
uklotzde c94df9d
Use deleteAfter() for cached track objects
uklotzde 70c4c2b
Merge branch '2.1' into lp1744550_globaltrackcache
uklotzde 521a382
Verify that post-evict actions are not executed from different threads
uklotzde 458f0e4
Replace std::pair<> with TrackRefPtr
uklotzde f972ef9
Fix destruction of GlobalTrackCache
uklotzde e06d531
Fix nasty debug assertion after introduction of TrackRefPtr
uklotzde 75afcd7
Check main thread assumption in evictor callback implementation
uklotzde 3849582
Fix VS2015 build
uklotzde 6c2c700
Don't use GlobalTrackCache from BrowseThread
uklotzde ae569aa
Simplify TrackRefPtr
uklotzde a7a41cb
Extend global track cache test harness
uklotzde f645406
Reliably suppress emitting signals when evicting and deleting a track
uklotzde ce4c67f
Just block signals, don't disconnect
uklotzde 150c53a
Clarify why race-conditions are expected to occur
uklotzde eec0682
Delete unused parameter
uklotzde 9ff719e
Inline member function
uklotzde d78bc08
Simplify lookup of cached tracks
uklotzde 8a22aaf
Merge branch '2.1' into lp1744550_globaltrackcache
uklotzde d878f94
Only deactivate but do not destroy GlobalTrackCache when exiting
uklotzde 98593a6
Shorten member function name
uklotzde dec9f65
Remove redundant code and slim down GlobalTrackCacheLocker
uklotzde 9fe2cfb
Avoid move assignment
uklotzde d4774d7
Replace derived TrackPointer class with a typedef
uklotzde 2da3059
Use workaround to prevent spurious crashes
uklotzde 0bffc94
Reduce complexity of GlobalTrackCache
uklotzde 8691074
Reorder member functions around GlobalTrackCache
uklotzde c511036
Fix debug assertion: Missing tracks don't have a canonical location
uklotzde 450c092
Use unordered_map/set
uklotzde 06dae38
Drop DbId::toInt()
uklotzde 8dc437a
Export metadata of track if requested by the user
uklotzde c892866
Show information about deferred/delayed export of metadata
uklotzde cf00fd8
Don't mark as dirty when modifying transient data
uklotzde bc9a898
Merge branch 'lp1748758_mark_track_for_export_metadata' into lp174455…
uklotzde 91f49f2
Check for correct thread when accessing the database
uklotzde d53befb
Update database in main thread when deleting tracks
uklotzde 986473e
Prevent concurrent read/write access of track files
uklotzde 1def331
Merge branch '2.1' into lp1744550_globaltrackcache
uklotzde 53e1981
Merge branch '2.1' into lp1744550_globaltrackcache
uklotzde 4d71f52
Keep the cache locked while saving and deleting tracks
uklotzde 98dc9ea
Don't delete any tracks after the cache has been destroyed
uklotzde d3b7054
Add comment about (currently) unused function
uklotzde 94d6ad1
Reword comment about expected and handled race conditions
uklotzde 25368a4
remove unused m_unindexedTracks
daschuer 6af8bc5
Remove unneccesary code
daschuer 4a5d770
Improve comments
daschuer 3eff006
Don't throw any exceptions during the deletion of track objects
uklotzde a5c15de
Relocate cached tracks
uklotzde 95c8fcb
Replace throw() with noexcept
uklotzde b6e2f63
Delete confusing try/catch block in noexcept function
uklotzde 6c19f05
Do not delete shared track pointers until expired/released
uklotzde 838c668
Improve comments
daschuer 8b5a0eb
Fix saving and deleting tracks at Mixxx shutdown.
daschuer ac09175
remove redundant TrackPointer temporary
daschuer b4f1f51
use std::move to avoid reference counting
daschuer 163203c
Avoid locking in inner loop
daschuer c3337f7
void passing a Track plain pointer
daschuer c463541
Simplify code and add/reword/fix some comments
uklotzde 4abb74e
Rename member to better reflect its purpose
uklotzde 75c0ece
Add comments about why we are using a plain pointer
uklotzde 2783fde
Reduce visibility of callback functions
uklotzde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Ups. We have many statement like this in the code.
Is the a bug report we can reference? Which places may also be effected?
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.
No. I wasn't able and did not have the time to isolate this issue for a proper bug report.
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.
What means sooner or later? Did this happen with the plain std::shared_ptr or the inherited class or both?
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.
As described, after the assignment the left hand side argument is null, even if the right hand side argument was non-null before the assignment. This is impossible and cannot be caused by a race condition if we assume (and we really should) that std::shared_ptr is thread-safe! It happens with the plain std::shared_ptr, but only once in a while. I was not able to create a simple test case that reproduces the crash.
The optimizer might be confused by the cascaded invocation of const member functions that in the end modify some mutable members. Just an idea, but I cannot proof it.
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.
Do I need to mention how many hours I spend to discover this subtle bug? I'm really annoyed about C++ now, totally frustrating.