Hi is there a way for me to make invalid read or writes to raise an exception?

Hi is there a way for me to make invalid read or writes to raise an exception? Using Valgrind I see that I am writing to / reading from memory that was previously allocated. I know that by chance I might get a segmentation fault, but is there a way for me to write a unit test to reproduce this with a high likelihood?

What is happening in the program is that a method of an object is called in a separate thread, and while executing, the underlying object is deleted, leading to invalid memory access when the method tries to access the data members.
You already invited:

Brian

Upvotes from:

What about compiling your unit tests with `-fsanitize=address`?

If you wanna answer this question please Login or Register