• Artem Bolgar's avatar
    Fixing "Abort message: '[FATAL:decoder_stream.cc(524)] OnDecodeDone<audio>: 0" in dev/debug · 30e5d69e
    Artem Bolgar authored
    Dev and debug versions throw DCHECK in OnDecodeDone due to wrong syntax of logging statement:
    ```
    FUNCTION_DVLOG(status.is_ok() ? 3 : 1) << ": " << status.code();
    ```
    The FUNCTION_DVLOG is defined as follows:
    ```
      DVLOG(level) << __func__ << "<" << GetStreamTypeString() << ">"
    ```
    
    The issue is that the condition "status.is_ok() ? 3 : 1" should become "level", but in reality, since there are no braces around it, it gets parsed incorrectly and the number "3" becomes a severity level (see base/logging.h), which corresponds to "FATAL" severity level, which ends up which crash / assert.
    
    Here is the code after preprocessor for that line 524 BEFORE the fix:
    
      !(((status.is_ok() ? 3 : 1) <= ::logging::GetVlogLevel("../../media/filters/decoder_stream.cc")) && (true)) ? (void) 0 : ::logging::LogMessageVoidify() & (::logging::LogMessage("../../media/filters/decoder_stream.cc", 524, -status.is_ok() ? 3 : 1).stream()) << __func__ << "<" << GetStreamTypeString() << ">" << ": " << status.code();
    
    and this is the fixed version:
    
      !((((status.is_ok() ? 3 : 1)) <= ::logging::GetVlogLevel("../../media/filters/decoder_stream.cc")) && (true)) ? (void) 0 : ::logging::LogMessageVoidify() & (::logging::LogMessage("../../media/filters/decoder_stream.cc", 524, -(status.is_ok() ? 3 : 1)).stream()) << __func__ << "<" << GetStreamTypeString() << ">" << ": " << status.code();
    
    Pay attention to this part:
    
    LogMessage("../../media/filters/decoder_stream.cc", 524, -status.is_ok() ? 3 : 1).stream())
    
    and
    
    LogMessage("../../media/filters/decoder_stream.cc", 524, -(status.is_ok() ? 3 : 1)).stream())
    
    So, basically, before the fix the negative sign is applied to the wrong statement, therefore the LogMessage will get +3 instead of -3. +3 means FATAL, while -3 means verbosity level 3, as far as I understand.
    
    Fixed: 1157701, 1156942
    Change-Id: I3132dde1dbd7d18460b74715016b74228e52ad7a
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586656Reviewed-by: default avatardanakj <danakj@chromium.org>
    Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
    Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
    Commit-Queue: Artem Bolgar <artyom@fb.com>
    Cr-Commit-Position: refs/heads/master@{#836357}
    30e5d69e
logging.h 30.1 KB