The Bug That Ruined My Weekend
Join the DZone community and get the full member experience.Join For Free
this is bloody strange. i have a test failing in our unit tests, which isn’t an all too uncommon occurrence after a big work. the only problem is that this test shouldn’t fail, no one touched this part.
for reference, here is the commit where this is failing . you can reproduce this by running the raven.tryouts console project.
note that it has to be done in release mode. when that happens, we consistently get the following error:
unhandled exception: system.nullreferenceexception: object reference not set to an instance of an object. at raven.client.connection.multigetoperation.<tryresolveconflictorcreateconcurrencyexception>d__b.movenext() in c:\work\ravendb\raven.client.lightweight\connection\multigetoperation.cs:line 156 --- end of stack trace from previous location where exception was thrown --- at system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) at system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task)
here is the problem with this stack trace:
now, this only happens in release mode, but it happens there consistently. now, i’ve verified that this isn’t an issue of me running old version of the code. so this isn’t possible. there is no concurrency going on, all the data this method is touching is only touched by this thread.
what is more, the exception is not thrown from inside the foreach loop in line 139. i’ve verified that by putting a try catch around the inside of the loop and still getting the nre when thrown outside it. in fact, i have tried to figure it out in pretty much any way i can. attaching a debugger make the problem disappear, as does disabling optimization, or anything like that.
in fact, at this point i’m going to throw up my hands in disgust, because this is not something that i can figure out. here is why, this is my “fix” for this issue. i replaced the following failing code:
with the following passing code:
and yes, this should make zero difference to the actual behavior, but it does. i’m suspecting a jit issue.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.