Posts

Showing posts with the label Bugs

C++: Undefined behaviour from realloc and the Clang Optimizer

Image
I was wondering around in some system code and found a strange behaviour between two modes in a piece of code, where the code switches from double to triple buffer mode there's a problem, we've already got two buffers of everything we just want to allocate another but the underlying structure for sets of buffers wants to own them all... So the code went from: SetOfBuffers { Buffer* one; Buffer* two; } To: SetOfBuffers { Buffer* one; Buffer* two; Buffer* three; } Creating the third buffer is fine: SetOfBuffers::three = malloc(X); But, the first two is a re-alloc, to reuse the existing buffer: SetOfBuffers::One = realloc(OldSet::one, X); SetOfBuffers::Two = realloc(OldSet::two, X); The problem?  I'd start to modify the values in the new set of buffers, the third buffer being used and present.  Then the first buffer would be changed present... The second buffer changed present and the information is wrong (I over simplify massively here). Anyway, I was remotely SSH'd ...

When Software Tries to be Cute

Image
Developers of the world, unite, and stop listening to sales-folks who say that variety is the spice of life, that you need to make your programs do cute things, like vary the replies it gives.  You are only causing yourself more trouble testing, debugging and annoying your users. Users of the world, unite, and stop wanting stupid cute differentiation replies from programs to make you feel special.  You are not special, you are one of very many using the same program, be like normal people and expect the action of something to have the general same reaction so you can see when things go wrong. I bring this up, as I recently had the Ultimate Ears Blast App, and it was too busy being cute with "just a moment", "hang on in there", "be right with you" bullshit replies to actually work!  Yes, it looked to me they were trying too hard to be hip that actually hit the mark! And YouTube has just done the same thing, check this out.... Same machine, same time, same b...