Thursday, August 26, 2021
The case of the regression test regression, part IV
Like all bugs,
it was a simple fix once identified—it was just identifying the bug that was difficult.
The bug was due to a semantic change in an API.
Lua has a file interface that includes a read()
function,
and the parameter it's given dictates how much to read.
One of the parameters is “a”
(or “*a” if you are using Lua 5.1)
that indicates you want to read all possible data until the end-of-file is reached.
I ended up writing my own read()
function to deal with network activity.
I couldn't just open up a normal Lua file object with a network connection because that doesn't work nicely with event driven programs.
An earlier version of my read()
function had a different semantic meaning with “a”—it just returned any buffered data.
It was in a later change where I aligned the semantics to match Lua's semantics,
but forgot to change that bit of code in the one component.
And those semantic changes explain the behavior I was seeing yesterday.
It only took what?
A week?
To find the culprit.
Now the regression test with the updated code runs as fast as the previous version.