Thread overview
Nondeterministic unittest debugging problem.
Aug 15, 2021
Rekel
Aug 15, 2021
Rekel
Aug 16, 2021
wjoe
Aug 16, 2021
russhy
Aug 17, 2021
Rekel
August 15, 2021

I am unsure where to mention this as I am utterly lost as to what the issue is, which I can simply best describe with 2 screenshots. Though I'll first give a short description.

For some reason my debugger is "<Unable to read memory>" for one of my variables in one of my unittests. This is however not the case when a random unused variable is inserted in front of it. (For reference I'm building the unittest using something similar to dub build --build=unittest --config=unittest --force --archType=x86_64, though the project is a library thus there are some complications: https://github.com/dlang/dub/issues/1856#issuecomment-899022431)

Not readable:

Readable:

int x = 0;
Mat!(3, 3, float) a = Mat!(3, 3, float)([1, 2, 3, 4, 5, 6, 7, 8, 9]);

Note the x variable is entirely unused while Mat is a struct of a union that is essentially just a 2d array of floats.

I have no more clue where to look as I have no clue what could cause this, am I overlooking something trivial? Thanks in advance.

August 15, 2021

Note you might need to open the screenshots externally, as they are cut off by the forum.

August 16, 2021
On Sunday, 15 August 2021 at 10:32:27 UTC, Rekel wrote:
> Note you might need to open the screenshots externally, as they are cut off by the forum.

This looks like your build system fails to detect file changes and links outdated .o file(s), or library, which causes a mismatch between your debug info and the real location of the variables. This leads the debugger to look in the wrong place and hence can't read the memory. By inserting the variable int x, Mat a is then again on the stack frame where it's supposed to be according to the debug info. That's my guess anyways.

When I encounter a problem like this I do a 'clean all' followed by a full rebuild of both, the lib and the program using it.
August 16, 2021
remove the .dub folder and try again, as stated in other reply, might be a cache issue, or something that picks an outdated file in the cache
August 17, 2021
On Monday, 16 August 2021 at 22:01:21 UTC, russhy wrote:
> remove the .dub folder and try again, as stated in other reply, might be a cache issue, or something that picks an outdated file in the cache

Thanks, I'll try that, sadly clear didn't seem to fix it.