Skip to content

C++ Extractor freezes when reading specific code pattern #16094

@philipp-naused

Description

@philipp-naused

We've had trouble with CodeQL freezing when reading some old C++ code.
Here is a very minimalist example of code that can trigger this behavior:

char *Foo(size_t &size, char *target)
{
  return target ? target : (char *)(size = 0, 0);
}

If you compile this with the MSVC compiler (cl /c test.cpp), everything is fine.
But when running it in the database create command, extractor.exe seems to get stuck in a busy loop.
e.g:
.\codeql\codeql database create db --language=cpp --command="cl /c test.cpp"

A process with path: \codeql\cpp\tools\win64\extractor.exe and args --mimic "c:\program files\microsoft visual studio\2022\professional\vc\tools\msvc\14.39.33519\bin\hostx86\x86\cl.exe" /c test.cpp
is running indefinitely, using exactly 1 CPU core, and is not performing any operations that show up in "Process Monitor".

This is not a new issue. We have observed the same problem with older versions of the compiler and of CodeQL ever since we started using it, so I cannot say when this issue was introduced.

I have attached the log files from the CodeQL database:
log.zip

OS: Windows 10
Compiler: MSVC 14.39 (As part of Visual Studio Professional 17.9.5)
CodeQL Version: 2.16.6 (https://github.com/github/codeql-action/releases/download/codeql-bundle-v2.16.6/codeql-bundle-win64.tar.gz)

Please let me know if you need any more info.

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions