#Segmentation Fault Invalid Read of Size 8
10 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.
could you post the exact error message?
it will also be hard to troubleshoot without seeing where you define arr and how it changes throughout your code. according to google you may have used delete to free memory and now you can't access it anymore
• type three "backticks" (not quotes/apostrophes, on QWERTY layout, left of 1-key)
• on the same line, type the file extension for that language (c or cpp)
• enter your code on a new line and put another three backticks at the end
```cpp
int main() {
return 0;
}
```
int main() {
return 0;
} ```
most likely location is an invalid index
so when you try to access that element, it doesn't let you and crashes
location needs to be strictly (not equal to) less than the size of arr
Sanitizers are tools which generate additional code in your program that can catch many common programming mistakes, such as:
• accessing arrays out of bounds
• signed integer overflows
• race conditions
Not all sanitizers can be combined, but when they can, use e.g.:
-fsanitize=address,undefined to combine them. Always compile with debug info to get line numbers, variable names, etc.
• -fsanitize=address
• -fsanitize=undefined
• -fsanitize=thread
• -g for debug info
• -fsanitize=address
• -fsanitize=undefined
• -fsanitize=thread
• -fsanitize=memory
• -g for debug info
• -fsanitize=address
• -Zi for debug info
int main(void) {
int x;
return x;
} ```
SUMMARY: MemorySanitizer: use-of-uninitialized-value /tmp/test.cpp:3:5 in main
Exiting
(3:5is line and column ofreturn)
This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.