✅ How to test for memory corruption in your implementation
So I have a method
Foo
that does some SIMD and pointer shenanigans. Now I want to write tests for it. One thing I'd like to test is out of bounds accesses of the data I process. My thought was that I setup three contiguous pages [A B C] and apply a page guard to A and C while the entirety of B contains the test data. The idea is Foo going out of bounds is not a critical error in this test, it should simply fail the test. The problem is: in order to use page guards I have to make the page read only. However, making the page read only triggers an AccessViolationException
in C# when I write to it and the process is shut down. Since [HandleProcessCorruptedStateExceptions]
is no longer supported I cannot prevent the entire process from shutting down.
Any idea on how I can test for out of bounds accesses without killing the entire process?2 Replies
Unknown User•5d ago
Message Not Public
Sign In & Join Server To View
Will do, thanks for the pointer