streamOut->getResult() crash


I've been staring at this all afternoon trying to figure out why it's crashing. My juce version is from Git Dec 2, 2014. This is on Linux 32 bit.

My code looks like this:

File compFile(outputFilename);
compFile.deleteFile();          // delete old one first
FileOutputStream * streamOut = compFile.createOutputStream();
GZIPCompressorOutputStream *compOut = 0;

Result status = streamOut->getStatus();
if (streamOut && status.wasOk())
    compOut = new GZIPCompressorOutputStream(streamOut);

It crashes on the getResult() line. The code looks correct, and used to work until I upgraded my juce from a very old version. I was suspecting heap corruption from somewhere else, but it always crashes on this line of code. With heap corruption I'd expect it to crash somewhere else when I moved things around.

My call stack looks like this:

juce::Atomic<int>::operator++() at juce_Atomic.h:327 0x10c6f8
juce::StringHolder::retain() at 0x20dd28
juce::String::String() at juce_String.cpp:259 0x1bce1c
juce::Result::Result() at juce_Result.cpp:37 0x1b4efc
Compress() at Compress.cpp:155 0x12f5fc

Any ideas?


This is so bizarre. I changed the constructor to be:

FileOutputStream::FileOutputStream (const File& f, const size_t bufferSizeToUse)
    : file (f),
      fileHandle (nullptr),
      status (Result::ok()),
      currentPosition (0),
      bufferSize (bufferSizeToUse),
      bytesInBuffer (0),
      buffer (jmax (bufferSizeToUse, (size_t) 16))

And it crashes on the first openedOk(). I really don't understand what could be going on, the Result class is just a String.


Is "streamOut" null when you're calling getStatus()?


Yes, see my 2nd post, it's crashing as early as the constructor. The Result isn't getting initialized correctly for some reason.


Found it, I knew it was going to be something dumb. Preprocessor symbols DEBUG and _DEBUG didn't match between juce and my app.