Menu

#541 WinMain fails to parse unquoted argument (regression in 6.40)

6.44
closed
1
2022-12-24
2022-10-26
No

Thanks a lot for maintaining OWLNext!

I use C++Builder Community Edition (Clang compiler) with the most recent version of OWLNext (7.0, just downloaded with recent version of OWLMaker).

I have a slightly unusual setup — I pass command-line arguments to OWL-based programs. As such, I ran into a problem: the program does not run if there are unquoted command-line arguments. After debugging, I found that, on line 67 of "winmain.cpp", the argument to find_if is incorrect:

auto parseString = [](TIt& i, TIt end) -> tstring
{
  PRECONDITION(i != end);
  const auto e = find_if(i, end, [](tchar c) { return !_istspace(c); });
  const auto s = tstring{i, e};
  i = e;
  return s;
};

Since we are looking for the end of the word, we should find the first space character! However, we are looking for the first non-space character. This leads to an infinite loop and stack overflow.

Please remove the "!" operator, so that line 67 becomes:

const auto e = find_if(i, end, [](tchar c) { return _istspace(c); });

Thank you very much!

Test: Run any OWL-based program built with Clang with any command-line arguments:

program.exe any-argument

Note: parseQuotedString is correct!

Related

News: 2022/12/owlnext-709-and-64419-updates
Wiki: OWLNext_Stable_Releases

Discussion

  • Vidar Hasfjord

    Vidar Hasfjord - 2022-10-27

    Hi Konstantin, thanks for reporting this issue!

    It seems it is an error in the refactoring I did a while ago. See [r2844].

     

    Related

    Commit: [r2844]

  • Vidar Hasfjord

    Vidar Hasfjord - 2022-10-27
    • labels: --> Crash, Internal
    • summary: WinMain: bug in --> WinMain fails to parse unquoted argument (regression in 6.40)
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,29 +1,34 @@
    -Thanks a lot for maintaining OwlNext!
    +Thanks a lot for maintaining OWLNext!
    
    -I use C++ Builder community edition (clang compiler) with the most recent version of OWLNext (7.0, just downloaded with recent version of OWL Maker).
    +I use C++Builder Community Edition (Clang compiler) with the most recent version of OWLNext (7.0, just downloaded with recent version of OWLMaker).
    
    -I have slightly unusual setup - I pass command line arguments to OWL-based programs. So, I ran into a problem - the program does not run if there are unquoted command-line arguments. After debugging, I understood that on line 67 of winmain.cpp the argument in find_if is incorrect.
    +I have a slightly unusual setup — I pass command-line arguments to OWL-based programs. As such, I ran into a problem: the program does not run if there are unquoted command-line arguments. After debugging, I found that, on line 67 of "winmain.cpp", the argument to <tt>find_if</tt> is incorrect:
    
    -    auto parseString = [](TIt& i, TIt end) -> tstring
    -    {
    -      PRECONDITION(i != end);
    -      const auto e = find_if(i, end, [](tchar c) { return !_istspace(c); }); <<---
    -      const auto s = tstring{i, e};
    -      i = e;
    -      return s;
    -    };
    +~~~cpp
    +auto parseString = [](TIt& i, TIt end) -> tstring
    +{
    +  PRECONDITION(i != end);
    +  const auto e = find_if(i, end, [](tchar c) { return !_istspace(c); });
    +  const auto s = tstring{i, e};
    +  i = e;
    +  return s;
    +};
    +~~~
    
    -Since we are looking for the end of the word, we should find the first SPACE character! However we are looking for the first non-space char. Thus it leads to an infinite loop and stack overflow.
    +Since we are looking for the end of the word, we should find the first *space* character! However, we are looking for the first non-space character. This leads to an infinite loop and stack overflow.
    
    -Please remove ! sign, so that line 67 becomes
    +Please remove the "!" operator, so that line 67 becomes:
    
    -      const auto e = find_if(i, end, [](tchar c) { return _istspace(c); });
    +~~~cpp
    +const auto e = find_if(i, end, [](tchar c) { return _istspace(c); });
    +~~~
    
     Thank you very much!
    
    -///////////////////////
    -To test, run any OWL-based program, that is built with gcc/clang with any command-line args. 
    +**Test**: Run any OWL-based program built with Clang with any command-line arguments: 
    
    -program.exe anyargument
    +~~~bat
    +program.exe any-argument
    +~~~
    
    -NOTE, parseQuotedString is correct!
    +**Note**: <tt>parseQuotedString</tt> is correct!
    
    • assigned_to: Vidar Hasfjord
    • Group: unspecified --> 6.44
     
  • Vidar Hasfjord

    Vidar Hasfjord - 2022-10-27
    • labels: Crash, Internal --> Crash, Internal, Regression
    • status: open --> pending
     
  • Vidar Hasfjord

    Vidar Hasfjord - 2022-10-27

    This issue was fixed on the trunk in [r6213] by applying Konstantin's suggested fix, and the fix has been merged into 6.44 [r6214] and 7.0 [r6215].

     

    Related

    Commit: [r6213]
    Commit: [r6214]
    Commit: [r6215]

  • Vidar Hasfjord

    Vidar Hasfjord - 2022-12-24
    • status: pending --> closed
     

Log in to post a comment.