Instrumentation

Wednesday, June 21, 2017

More work on instrumentation, with the idea of moving more stuff to the recorder, so that it can be leveraged between projects.

Flight recorder

There was a bug that was introduced by this update to the ring code, and generated occasional data miscompare errors in the unit tests. There were three problems.

  • One was that moving from unsigned to uintptr_t means that integer promotion (automatically conversion of some expressions to int) may no longer happen in some expressions. Instead, we may get some other conversion to a larger type, including unsigned. The net result is that one expression that used to work OK with unsigned because it was implicitly comparing int values, i.e. signed comparison, turned into an unsigned comparison, which did not work. So I made the signed cast explicit. That only affected the test, though. Fixed in this commit.
  • Another one is that I botched the rewritten calls to the block-test functions, which could cause the writes to become blocking if there was no blocking function. This was fixed in this commit.
  • Another more serious issue was introduced when I rewrote the code to ensure that data read was contiguous for each call to ring_read. This lead to a premature udpate of the reader index, which allowed a writer to overwrite data we were reading. This was fixed in this commit.

Moral of the story: unit testing is good