Menu

#422 Crash/assertion failure at line 3229, ASFormatter.cpp

wont-fix
Crash (1)
2017-02-15
2017-02-12
Li Minggang
No

Discussion

  • Li Minggang

    Li Minggang - 2017-02-12

    Related config

     
  • Li Minggang

    Li Minggang - 2017-02-13

    The "currentChar" is '?' and charNum >= 2 is OK.

    So, the patch may be changing the assertion from "assert(currentChar == '+' || currentChar == '-');" to "assert(currentChar == '+' || currentChar == '-' || currentChar == '?');"

    I do not meet any problem since then.

     
  • Jim Pattee

    Jim Pattee - 2017-02-13
    • status: open --> pending
    • assigned_to: Jim Pattee
     
  • Jim Pattee

    Jim Pattee - 2017-02-13

    I can't reproduce this error.
    This function should not be called for a "?".
    Send the few lines causing the problam encloced in a function.

     
  • Li Minggang

    Li Minggang - 2017-02-14

    I tried to simplify the string, eg. ") ? _(". and reproduced the crash.
    The call stack is:

    MadEdit.exe!astyle::ASFormatter::isInExponent() Line 3229   C++
    MadEdit.exe!astyle::ASFormatter::updateFormattedLineSplitPointsOperator(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & sequence) Line 6944    C++
    MadEdit.exe!astyle::ASFormatter::appendOperator(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & sequence, bool canBreakLine) Line 2647 C++
    MadEdit.exe!astyle::ASFormatter::padOperators(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > * newOperator) Line 3742   C++
    MadEdit.exe!astyle::ASFormatter::nextLine() Line 1623   C++
    MadEdit.exe!MadEditFrame::OnToolsAstyleFormat(wxCommandEvent & event) Line 9241 C++
    .....
    

    I traced into the souce code and found that in ASFormatter::updateFormattedLineSplitPointsOperator, line 6943.
    The code has a possiblity to trigger the assert. You can see the third condition is "?".

    else if (sequence == "+" || sequence == "-" || sequence == "?")
    {
    if (charNum > 0
    && !isInExponent()
    && (isLegalNameChar(currentLine[charNum - 1])

    This is the root cause.

     
  • Jim Pattee

    Jim Pattee - 2017-02-14
    • status: pending --> wont-fix
     
  • Jim Pattee

    Jim Pattee - 2017-02-14

    Works OK.

     
  • Li Minggang

    Li Minggang - 2017-02-14

    Can you explain more? It would definitely cause crash at the line mentioned if sequence == "?", charNum >0 and currentChar == '?'.

     
  • Li Minggang

    Li Minggang - 2017-02-15

    It's related to some configuration item of Astyle. I can't reproduce it with different config. Will try to narrow down.
    However, based on the code snippet listed above. It's definitely an bug.

     

Log in to post a comment.

MongoDB Logo MongoDB