Skip to content

Replace invalid vector.end dereference with raw pointer access #2471

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 1 commit into from
May 16, 2023
Merged

Replace invalid vector.end dereference with raw pointer access #2471

merged 1 commit into from
May 16, 2023

Conversation

LowLevelMahn
Copy link
Contributor

@LowLevelMahn LowLevelMahn commented May 11, 2023

the MSVC STL asserts on end dereference in Debug mode, that happens if there is no data left to copy (size == 0)
the assert happens under Linux only with -D_GLIBCXX_DEBUG

@dreamer
Copy link
Member

dreamer commented May 12, 2023

@kcgen maybe we should add _GLIBCXX_DEBUG to on of our builds to see if we can trigger this assert in CI (maybe clang static analysis build will manage to trigger this?).

@dreamer
Copy link
Member

dreamer commented May 12, 2023

@LowLevelMahn update the commit message according to rule 5, please.

@dreamer dreamer requested a review from kcgen May 12, 2023 14:45
@dreamer dreamer added the bug Something isn't working label May 12, 2023
@LowLevelMahn
Copy link
Contributor Author

@LowLevelMahn update the commit message according to rule 5, please.

so "replaces" becomes "Replace"?

@LowLevelMahn
Copy link
Contributor Author

@kcgen maybe we should add _GLIBCXX_DEBUG to on of our builds to see if we can trigger this assert in CI (maybe clang static analysis build will manage to trigger this?).

does the CI also start dosbox (its only triggered at runtime)?

@kcgen
Copy link
Member

kcgen commented May 12, 2023

@kcgen maybe we should add _GLIBCXX_DEBUG to on of our builds to see if we can trigger this assert in CI (maybe clang static analysis build will manage to trigger this?).

Yes - seems like we should have this in our debug builds? We should catch these straight away in a debug (and assert-enabled) builds.

@LowLevelMahn LowLevelMahn changed the title replaces invalid vector.end dereference with raw pointer access Replace invalid vector.end dereference with raw pointer access May 12, 2023
@LowLevelMahn
Copy link
Contributor Author

LowLevelMahn commented May 12, 2023

there is also _GLIBCXX_SANITIZE_VECTOR (see: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html)

When defined, std::vector operations will be annotated so that AddressSanitizer can detect invalid accesses to the unused capacity of a std::vector.

and the libc++ from the LLVM project also got sanitizing for std::string, std::vector, std::deque and some others

but i didn't tested them

@kcgen
Copy link
Member

kcgen commented May 16, 2023

Looks good, thanks @LowLevelMahn !

@kcgen kcgen self-requested a review May 16, 2023 16:06
@kcgen kcgen merged commit 2c50a26 into dosbox-staging:main May 16, 2023
@LowLevelMahn LowLevelMahn deleted the llm/end-dereference branch May 18, 2023 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants