-
Notifications
You must be signed in to change notification settings - Fork 22
Fix #4: Segfault on nonexisting disk image #19
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
lenticularis39
merged 17 commits into
lenticularis39:main
from
RaymiiOrg:segfault_on_nonexisting_disk_image
Nov 7, 2020
Merged
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9125eea
Add std::filesystem to cmake and add a helper header file to overcome…
523f278
Change build gitignore folder to include wildcard.
dfcc4eb
* Split up disk file actions into separate functions.
4678b29
Include local headers first
364bdd5
Use fstream to create the file (if it doesnt exist)
f8996b6
Add comments and use default file size of 2GB
f002476
Whitespace
f66b17b
Merge review comments: do not use c++17 features just to check if fil…
361b5dc
Merge review comments:
112b355
Merge review comments: remove unused function
de71705
Formatting, whitespace and newlines
0248130
std::ios::out flag not required when using ofstream (it's implicit then)
e387224
Move .clang-format, otherwise clion cannot use it for automatic forma…
557dbe3
segfault seems to be caused by iNumComponents being 8 but acComponent…
4f81ac6
Formatting, CLion complained about wrong encoding due to this quote.
202b122
Remove unneeded whitespace change
c16f58d
Remove if check (that checked the wrong index anyway)
RaymiiOrg 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
File renamed without changes.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| cmake-build-debug/ | ||
| cmake-build-release/ | ||
| build/ | ||
| build**/ | ||
| .idea/ |
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
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.
I'm not sure if unregistering a component this way is a good idea - the destructors may be called in a different order that the constructors.
Maybe the component storing its number and checking for that would help with this?
(I don't generally like the component managing its registration in
CSystem, but that's another issue.)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.
I think comparing by memory address is less likely to cause race condition when components are destructed i another order. A counter would have to be atomic, and a for loop to compare all items would have the same crash behavior.
Catching the exception at creation and then handling it would be another solution but that would also require some refactoring of the component registration (it happens so early in the base class, it be better if it was registering after constructing for this bug).
I could try to just not set it to a nullptr because it will be deleted right after the call to stop threads? Or try how a std::atomic counter would perform? What has your preference?
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.
You are right - I missed that the component number couldn't be read from an uninitialized component. I take my comment back, you can keep the code as it is.
Uh oh!
There was an error while loading. Please reload this page.
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.
I might be missing something, but doesn't the if before the nullptr setting check the wrong index?
iNumComponentsis increased inCSystem::RegisterComponent, so it should point to the next (empty) element, not to the last one. If that's the case then the setting to nullptr isn't needed, because it clearly works without 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.
Yes you are right, it checks the wrong component. The entire check can be removed, I'll do that right away.
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.
That's done, now it just decrements the counter.