Tuesday, June 2, 2009

Bugs cuánticos

Ayer en el trabajo me topé con un bug que parecía seguir los principios de la física cuántica, específicamente el "efecto observador". A bit of context (and an appropiate name) I found in Wikipedia in this article:
The name "heisenbug" is a pun on the "Heisenberg uncertainty principle," a quantum physics concept which is commonly (yet inaccurately) used to refer to the fact that in the Copenhagen Interpretation model of quantum mechanical behavior, observers affect what they are observing, by the mere act of observing it alone (this is actually the observer effect, and is commonly confused with the Heisenberg uncertainty principle).

El problema era que si corría un test, cuando quería llamar a un Stored Procedure de SQL a través de SubSonic (un Framework para eso), el programa terminaba con un NullReferenceException. Pero si corría el programa paso por paso, y usaba Visual Studio para ver los contenidos de la variable que supuestamente era Null Reference, sí había algo, y si seguía corriendo el programa, todo corría perfecto.

So, me observing the variable changed the result of the experiment. Finalmente encontré que era un bug de SubSonic, en el que las llamadas a SPs sin parámetros no crean bien el objeto si no se accede a una propiedad específica, que se usa por defaul al crear SPs con parámetros. Encontré un workaround, y listo. Pero fue un bug interesante jeje.

No comments: