C++ extractor fails to process code based on Unreal Engine
- Lenguaje dominante
- CodeQL
- Estrellas
- 10.1k
- Forks
- 2.1k
- Merge medio
- 2 d 15 h
- PR fusionados (30 d)
- 141
Descripción
Hey team,
I am trying to build a CodeQL database for a [sample](https://docs.unrealengine.com/4.27/en-US/Resources/Templates/FirstPerson/) Unreal project. Building the code base on Unreal Engine includes two main steps:
1. Running [`UnrealHeaderTool`](https://docs.unrealengine.com/4.27/en-US/ProductionPipelines/BuildTools/UnrealHeaderTool/) that parses the C++ headers for Unreal-related class metadata and generates custom C++ code.
2. Running the normal C++ compiler to compile the generated code.
Unreal Engine also has `UnrealBuildTool` that runs the above steps.
I use the following command to build the CodeQL database:
```
codeql database create --language=cpp --overwrite --command=run_build_tool.bat -- codeql-db
```
where `run_build_tool.bat` contains this:
```
"c:\Program Files\Epic Games\UE_4.27\Engine\Binaries\DotNET\UnrealBuildTool.exe" FirstPersonTemplate Win64 Development -Project=d:\projects\codeql\unreal\FirstPersonTemplate\FirstPersonTemplate.uproject -log=build.log
```
The `codeql database create ...` command finishes successfully. The `codeql database print-baseline codeql-db` shows about 3K lines of C++ code. The following query returns a list of files included into the database:
```
import cpp
from File f
select f, "file"
```
However, the database doesn't not include any function call, if-blocks, etc although the code have them. For example, the following query doesn't return anything:
```
import cpp
from FunctionCall call
select call, "function call"
```
I see multiple errors in `build-tracer.log` like this:
```
CodeQL C++ extractor: Current location: E:\projects\unreal\FirstPersonTemplate\Source\FirstPersonTemplate\FirstPersonTemplateGameMode.cpp:507675,0
CodeQL C++ extractor: Current physical location: E:\projects\unreal\FirstPersonTemplate\Source\FirstPersonTemplate\FirstPersonTemplateGameMode.cpp:17,0 (end of source)
Internal error: assertion failed at: "class_decl.c", line 33485 in diagnose_duplicate_capture
[E 16:25:56 12932] Warning[extractor-c++]: In construct_message: Internal error: assertion failed at: "class_decl.c", line 33485 in diagnose_duplicate_capture
1 catastrophic error detected in the compilation of "E:\projects\unreal\FirstPersonTemplate\Source\FirstPersonTemplate\FirstPersonTemplateGameMode.cpp".
Compilation aborted.
```
Does it look like a bug in the C++ extractor, or am I doing anything wrong?
Steps to reproduce:
1. [Install Unreal Engine 4](https://docs.unrealengine.com/4.27/en-US/Basics/InstallingUnrealEngine/)
2. [Create a sample first-person project](https://docs.unrealengine.com/4.27/en-US/Resources/Templates/FirstPerson), select C++ instead of Blueprint
3. Build a CodeQL database as described above
4. Check errors in `codeql-db/log/build-tracer.log`
5. Run the query above that looks for function calls
My testing environment:
* CodeQL CLI v2.14.2
* Windows 10 x64
* Visual Studio 2019 toolchain (tested with 2022 -- same results)
* Unreal Engine 4.27
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.