Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Is your code threaded ? I've seen that countless times where the debugger is all it took to break deadlocks.
-
@devphobe There's no threading in my code.
Also the weird behavior happens only when the vector is observed, when it's removed from the watches the code crash as expected -
@CodeTalker I wish I hadn't given up C++ for easier languages. Good luck, I'd love to know what it turns out to be.
-
Out of bounds access can work or crash, depending on what's before or behind the buffer. The memory layout in debugging mode is usually different so that sometimes, things don't crash because non-essential stuff is garbled up.
-
Root825575y@Fast-Nop This.
If things change in different environments, look at how the environments differ. It sounds like you're looking at a buffer overflow issue, which inherently means undefined behavior. Check the length first!
As an example: if you're using null-terminated cstrings, check for the terminator and fail/die if it's nonzero or missing. And then check where your memory is getting allocated/set! -
Root825575y@AlgoRythm Makes sense. Automatically zeroing out memory is a waste of cycles. Shouldn't happen in debug if it doesn't happen at runtime, though.
However, the differing memory layout @Fast-Nop mentioned absolutely makes sense! -
@Fast-Nop Well I badly addressed it: the code doesn't crash actually, I made a check for the function that throws an error if the vector is bigger than a defined size, so I don't think there's a buffer overflow
Related Rants
-
xjose97x19Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop.
-
Unskipp24So this happened last night... Gf: my favorite bra is not fitting me anymore Me: get a new one ? Gf: but it ...
-
sam966911Hats off to this lady .... I would have just flipped the machine
Introducing the quantum symbol.
I have a function throwing an error when passed a vector which has an unexpected size.
When I use the debugger and try to watch said vector for write access, the code which failed at some point just does… things. I have no idea what it is doing instead of failing but it is doing it gladly. It's not even paused, at least for the debugger.
Now I know why they said C++ is challenging to debug.
rant
c++
you hate me ? fine i hate you too
shrödinger's debugger