Menu

#562 Assert in 'ASResource.cpp'

closed
assert (1)
2024-09-11
2024-02-16
Gisle Vanem
No

Using astyle.exe on a large complex .cpp-file from the FileZilla-server project like this:

clang-cl -E @clang-cl++.args -DBUILDING_SERVER_GUI \
    -I./server/src/src/gui -I./server/src/src/filezilla -std:c++20 \
    server/src/src/gui/serveradministrator/updates.cpp | 
    py -3 cpp-filter.py | astyle >> server_gui_updates.i

(from a GNU-makefile where cpp-filter.py simply drops empty lines)
causes this assertion:

Assertion failed: isCharPotentialHeader(line, i), file ASResource.cpp, line 672

Call-stack:

ucrtbase!abort+0x4e
ucrtbase!common_assert_to_stderr_direct+0xb2
ucrtbase!common_assert_to_stderr<wchar_t>+0x1d
ucrtbase!wassert+0x71
astyle!astyle::ASBase::findKeyword(class std::basic_string<char,std::char_traits<char>,std::allocator<char> > * line = 0x000000ce`ab4ff130 "typedef struct __declspec (align (16)) _M128A", int i = <Value unavailable error>, class std::basic_string<char,std::char_traits<char>,std::allocator<char> > * keyword = 0x00007ff7`1b08a330 "struct")+0x57
astyle!astyle::ASBeautifier::parseCurrentLine(class std::basic_string<char,std::char_traits<char>,std::allocator<char> > * line = 0x000000ce`ab4ff130 "typedef struct __declspec (align (16)) _M128A")+0x11b2
astyle!astyle::ASBeautifier::beautify(class std::basic_string<char,std::char_traits<char>,std::allocator<char> > * originalLine = 0x000000ce`ab4ff7e8 "typedef struct __declspec (align (16)) _M128A")+0xd7d
astyle!astyle::ASFormatter::nextLine(void)+0x39d7
astyle!astyle::ASConsole::formatCinToCout(void)+0x20a
astyle!main(int argc = <Value unavailable error>, char ** argv = <Value unavailable error>)+0x2d8
astyle!invoke_main(void)+0x22
astyle!__scrt_common_main_seh(void)+0x10c
KERNEL32!BaseThreadInitThunk+0x14
ntdll!RtlUserThreadStart+0x21

So modifying ASBase::findKeyword() into this:

--- a/ASResource.cpp 2024-02-16 06:58:08
+++ b/ASResource.cpp 2024-02-16 08:24:17
@@ -668,8 +668,12 @@
 // check if a specific line position contains a keyword.
 bool ASBase::findKeyword(const std::string& line, int i, const std::string& keyword) const
 {

-       //std::cerr << "findKeyword "<< i << " "<< line << " -< "<< keyword << "\n";
-       assert(isCharPotentialHeader(line, i));
+       bool is_hdr = isCharPotentialHeader(line, i);
+       if (!is_hdr) {
+          std::cerr << "findKeyword "<< i << " "<< line << " -< "<< keyword << "\n";
+          assert(false);
+        }
+
        // check the word
        const size_t keywordLength = keyword.length();
        const size_t wordEnd = i + keywordLength;

and rebuilding/rerunning the above command, I see:

findKeyword 26 typedef struct __declspec (align (16)) _M128A -< struct
Assertion failed: false, file ASResource.cpp, line 674

What is _M128A?

PS. This assert happens on several .cpp-files in the FileZilla-server project.
Since it's not in a SVN-repo, the server sources can be D/L here:
https://filezilla-project.org/download.php?type=server&show_all=1

Discussion

  • André Simon

    André Simon - 2024-03-06
    • status: open --> open-accepted
    • assigned_to: André Simon
     
  • André Simon

    André Simon - 2024-03-06

    Since "declspec" or "M128A" are not present in the original updates.cpp file the clang-cl call must produce something new. Possibly M128A is a macro which might confuse astyle. Could you please provide the output piped to astyle (or maybe just the portion which triggers the problem)?

     
  • André Simon

    André Simon - 2024-09-11
    • status: open-accepted --> closed
     

Log in to post a comment.

Monday.com Logo