github / codeql

CodeQL: the libraries and queries that power security researchers around the world, as well as code scanning in GitHub Advanced Security
https://codeql.github.com
MIT License
7.7k stars 1.54k forks source link

Potential segmentation fault in semmle_utils.cpp Logger / bazel? #13378

Open Plasma opened 1 year ago

Plasma commented 1 year ago

Description of the issue In the last few days I've started getting intermittent (say 10%) SIGSEGV crashes during dotnet restore and dotnet build when running under CodeQL via GitHub Actions Runner.

I've managed to capture a core dump and ran gdb backtrace on the offending thread from a GitHub Action Runner.

I notice in the stack trace context line 3 it mentions Logger::Logger in semmle_utils.cpp just before entering bazel_runner.

I don't have a separate test case, but I can re-run the build and every now and then it will trigger with a failure; without CodeQL there is no issue.

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `dotnet restore /home/runner/work/project/project/project/project.sln'.
Program terminated with signal SIGSEGV, Segmentation fault.
--Type <RET> for more, q to quit, c to continue without paging--c
#0  0x00007f5ebe8b4d11 in std::__1::__shared_count::__release_shared (this=0x55a493a19fe0) at /home/runner/.cache/bazel/_bazel_runner/9f4ed60bba64c867c2242caf607221b5/external/cc_linux_toolchain/bin/../include/c++/v1/__memory/shared_ptr.h:174
174     /home/runner/.cache/bazel/_bazel_runner/9f4ed60bba64c867c2242caf607221b5/external/cc_linux_toolchain/bin/../include/c++/v1/__memory/shared_ptr.h: No such file or directory.
[Current thread is 1 (Thread 0x7f1d55ff9640 (LWP 2031))]
(gdb)
(gdb)
(gdb)
(gdb)
(gdb) bt
#0  0x00007f5ebe8b4d11 in std::__1::__shared_count::__release_shared (this=0x55a493a19fe0)
    at /home/runner/.cache/bazel/_bazel_runner/9f4ed60bba64c867c2242caf607221b5/external/cc_linux_toolchain/bin/../include/c++/v1/__memory/shared_ptr.h:174
#1  std::__1::__shared_weak_count::__release_shared (this=0x55a493a19fe0)
    at /home/runner/.cache/bazel/_bazel_runner/9f4ed60bba64c867c2242caf607221b5/external/cc_linux_toolchain/bin/../include/c++/v1/__memory/shared_ptr.h:216
#2  std::__1::shared_ptr<global_state_t>::~shared_ptr (this=<optimized out>)
    at /home/runner/.cache/bazel/_bazel_runner/9f4ed60bba64c867c2242caf607221b5/external/cc_linux_toolchain/bin/../include/c++/v1/__memory/shared_ptr.h:703
#3  Logger::Logger (this=0x7f1d55ff7ee8) at c/tracers/shared/semmle_utils.cpp:235
#4  0x00007f5ebe8a7d6b in request_file (path=path@entry=0x7f1d55ff80d0 "/home/runner/.dotnet/TelemetryStorageService/20230606052549_25cdd4595fba42aba356228c2a6492eb.trn") at c/tracers/posix/libtrace.cpp:1302
#5  0x00007f5ebe8a82a4 in __lxstat64 (x=1, path=0x7f1d55ff80d0 "/home/runner/.dotnet/TelemetryStorageService/20230606052549_25cdd4595fba42aba356228c2a6492eb.trn", st=0x7f1d55ff7f80)
    at c/tracers/posix/libtrace.cpp:1452
#6  0x00007f5eb6c1b620 in SystemNative_LStat () from /usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.5/libSystem.Native.so
#7  0x00007f5e3ece735c in ?? ()
#8  0x000000000001b8d9 in ?? ()
#9  0x00007f5ebe18c2d8 in ?? () from /usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.5/libcoreclr.so
#10 0x00007f1d55ff8c10 in ?? ()
#11 0x0000000000000000 in ?? ()
(gdb)

GitHub Runner Image:

Image: ubuntu-22.04
Version: 20230517.1

CodeQL:

/opt/hostedtoolcache/CodeQL/2.13.3-20230524/x64/codeql/codeql version --format=json
{
  "productName" : "CodeQL",
  "vendor" : "GitHub",
  "version" : "2.13.3",
  "sha" : "d93[19](https://github.com/my-org/project/actions/runs/5184926281/jobs/9344299955#step:3:20)29688e85c41f9452f89c2ea2640bdae3a19",
  "branches" : [
    "codeql-cli-2.13.3"
  ],
  "copyright" : "Copyright (C) [20](https://github.com/my-org/project/actions/runs/5184926281/jobs/9344299955#step:3:21)19-20[23](https://github.com/my-org/project/actions/runs/5184926281/jobs/9344299955#step:3:24) GitHub, Inc.",
  "unpackedLocation" : "/opt/hostedtoolcache/CodeQL/2.13.3-202305[24](https://github.com/my-org/project/actions/runs/5184926281/jobs/9344299955#step:3:25)/x64/codeql",
  "configFileLocation" : "/home/runner/.config/codeql/config",
  "configFileFound" : false
}
hmakholm commented 1 year ago

Thanks for the bug report. I've asked our tracer experts to take a look at it.