Repository navigation
Conversation
…en Cppcheck crashes)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
This PR breaks the server's crash report for every crash that has an assertion message. glibc starts the message with the program's short name, so the line begins with cppcheck: , for example cppcheck: build/symboldatabase.cpp:6760: ...: Assertion ... failed. The PR puts this line into the head results: section, before the received signal line.
On the server, crashReport() (tools/donate-cpu-server.py:222) and the other reports treat any line that starts with cppcheck: as the version line. If OLD_VERSION is not in that line, they stop reading the file (break). The assertion line does not contain OLD_VERSION, so the server stops before the stack trace. The package is still listed as a crash, but its stack trace disappears from the "Stack traces" section. That is less information than before the change.
Either add a prefix to the message when it is written to the results (for example assertion: ...), or change the server's checks to match only the real version line.
No other problems found. The regex and the dedup logic behave as described.
Comments
| # | Comment | By | Where | Status |
|---|---|---|---|---|
| 1 | Assertion line starts with 'cppcheck: ', so the server stops parsing and the crash stack trace is lost | AI review | tools/donate_cpu_lib.py:574 |
🆕 New |
@danmar, please fix, resolve or reply to the open and new comments: #1.
Testing
-
I did not build the C++ code: the PR changes only Python (
tools/donate_cpu_lib.pyand its test). -
PYTHONPATH=tools python3 -m pytest -v test/tools/donate_cpu_lib_test.py: all 3 tests pass, including the newtest_get_assertion_failures. WithoutPYTHONPATH=toolsthe test cannot import the module. -
Server parsing test. I wrote a results file in the format that
donate-cpu.pyproduces, with the stack trace in the layout the PR creates. It is shown below, shortened:2026-11-28 10:00 ftp://ftp.de.debian.org/debian/pool/main/f/foo/foo_1.0.orig.tar.gz ... cppcheck: 2.22.0 head head-info: abc count: Crash! 0 ... head results: Checking /tmp/foo/a.c ... cppcheck: build/symboldatabase.cpp:6760: bool Variable::arrayDimensions(const Settings&, bool&): Assertion `dimension_.tok->values().size() == 1' failed. Program received signal SIGABRT, Aborted. 0x00007ffff7a9e9fc in __pthread_kill_implementation () from /lib64/libc.so.6 #0 0x00007ffff7a9e9fc in __pthread_kill_implementation () from /lib64/libc.so.6 #1 0x00000000006f2414 in Variable::arrayDimensions (this=0x1) at build/symboldatabase.cpp:6760I loaded
tools/donate-cpu-server.pywith importlib and calledcrashReport(dir, {})twice: once on this file, and once on the same file without the assertion line.- With the assertion line: the package is listed as
Crash, but the "Stack traces" section is empty. - Without the assertion line: the "Stack traces" section shows
Packages: foo,#0 __pthread_kill_implementation (...) from /lib64/libc.so.6and#1 Variable::arrayDimensions(...) at build/symboldatabase.cpp:6760.
The cause is the check
if line.startswith('cppcheck: '): if OLD_VERSION not in line: breakatdonate-cpu-server.py:222. - With the assertion line: the package is listed as
-
Regex spot checks: a trailing
\ris handled. A source path that contains spaces is not matched, which is a minor issue.
Automated review of 3218a05 by Claude. The pull request was built and tested locally.
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
The earlier problem is fixed. The program name is now stripped from the assertion message, so the server no longer reads that line as the version line, and the stack trace is parsed again.
One new problem: in a -j run, the messages from the first run's stderr are put into the gdb stack trace together with those from the gdb run. gdb re-runs only the first file that crashed. If several files crash with different assertions, every assertion message ends up just before the received signal line of that one file's stack trace. Messages from other crashes then look like they belong to this backtrace. I reproduced this with a fake cppcheck binary. Apart from that, end-to-end tests with a real glibc assert under gdb, with and without stack-trace capture, worked as intended.
Comments
| # | Comment | By | Where | Status |
|---|---|---|---|---|
| 1 | Assertion line starts with 'cppcheck: ', so the server stops parsing and loses the stack trace | AI review | general | ✅ Fixed |
| 2 | 'cppcheck: ' prefix of the assertion line is read as the version line by the server reports | AI review | tools/donate_cpu_lib.py:576 |
✅ Fixed |
| 3 | With -j, assertion messages from other crashed files are put into the gdb stack trace of the first crashed file | AI review | tools/donate_cpu_lib.py:565 |
🆕 New |
@danmar, please fix, resolve or reply to the open and new comments: #3.
Testing
- The PR changes only Python, so I did not build the C++ code. pylint is not installed in the container, so I did not run it.
PYTHONPATH=tools python3 -m pytest -q test/tools/donate_cpu_lib_test.py: all 3 tests pass.- End to end with real gdb. I compiled a fake
cppcheckthat printsChecking src/a.c ...and then fails a glibcassert, and calledlib.scan_package('/work/scratch/fake', '/work/scratch/src', [], capture_callstack=True).- The result is
Checking src/a.c ..., a blank line,f.c:3: foo: Assertionx == 1' failed., thenProgram received signal SIGABRTand the backtrace. The program name is stripped and the line sits before the signal line, so the server'scrashReport` parsing is not affected. - With
capture_callstack=Falsethe message is put at the start of the output. That is also correct.
- The result is
- Mis-attribution with
-j. I used a fake binaryg.c.- Without
-j1it emulates a parallel run. It writes two different glibc assertion lines and twoInternal error: Child process crashed with signal 6lines, forsrc/a.candsrc/b.c, to stderr and exits 1. - With
-j1it asserts incheckA. - Script:
lib.__jobs='-j2'; r = lib.scan_package('/work/scratch/fake','/work/scratch/src',[],True); print(r[1]) - Output:
Checking src/a.c ... lib/checkb.cpp:20: void checkB(): Assertion `y' failed. lib/checka.cpp:10: void checkA(): Assertion `x == 1' failed. g.c:4: checkA: Assertion `x == 1' failed. Program received signal SIGABRT, Aborted. #0 ... - The assertion from
src/b.c(checkB) is put into the stack trace ofsrc/a.c. - The third line differs from the second only because the fake prints a hand-written text in the first run. With the real binary the two messages would be identical and only one would be kept.
- Without
Automated review of f6aaa82 by Claude. The pull request was built and tested locally.
| cmd += dir_to_scan | ||
| _, st_stdout, _, _ = __run_command(cmd) | ||
| _, st_stdout, st_stderr, _ = __run_command(cmd) | ||
| for msg in get_assertion_failures(st_stderr): |
There was a problem hiding this comment.
AI review
assertion_failures starts with every assertion message in the stderr of the first run. With -j that run can contain assertions from several child processes that crashed on different files. gdb is re-run only on sig_file (the first file that crashed), but all of these messages are put just before the received signal line of that trace. A message from another crash then looks like it belongs to this backtrace.
I reproduced this with a fake binary. Its -j2 run writes the assertions for checkB (src/b.c) and checkA (src/a.c), and its gdb run asserts in checkA. The result is:
Checking src/a.c ...
lib/checkb.cpp:20: void checkB(): Assertion `y' failed.
lib/checka.cpp:10: void checkA(): Assertion `x == 1' failed.
Program received signal SIGABRT, Aborted.
Suggested fix: when the gdb run gives a stack trace, put only the messages from st_stderr before the signal line. Keep the messages from the first run for the fallback case where there is no gdb trace.
df598f3 to
4a34930
Compare
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
I found no new problems. Both earlier problems are fixed:
- The
cppcheck:program name is removed from the assertion message, so the server no longer reads that line as the version line. - When gdb produces a trace, only the assertion messages from the gdb run go into it. Messages from the first run are used only when there is no gdb trace, so in a
-jrun messages from other crashed files no longer end up in the trace.
The two new pytest tests cover both paths.
Comments
| # | Comment | By | Where | Status |
|---|---|---|---|---|
| 1 | Assertion line starts with 'cppcheck: ', so the server stops parsing and loses the stack trace | AI review | general | ✅ Fixed |
| 2 | 'cppcheck: ' prefix of the assertion line is read as the version line by the server reports | AI review | tools/donate_cpu_lib.py:577 |
✅ Fixed |
| 3 | With -j, assertion messages from other crashed files are put into the gdb stack trace of the first crashed file | AI review | tools/donate_cpu_lib.py:565 |
✅ Fixed |
Testing
-
I did not build the C++ code, because the PR changes only Python (
tools/donate_cpu_lib.pyand its test). -
PYTHONPATH=tools python3 -m pytest -q test/tools/donate_cpu_lib_test.py: all 5 tests pass, including the 3 new ones. -
End to end with real gdb. I used a fake
cppcheckwritten in C:- Without
-j1it writes a glibc assertion line and aChild process crashed with signal 6line to stderr and exits with 1. - With
-j1it printsChecking src/a.c ...and then fails a realassert.
Script:
lib.__jobs='-j2'; lib.scan_package('/work/scratch/f','src',[],capture_callstack)capture_callstack=True: the result isChecking src/a.c ..., a blank line,f/c.c:6: main: Assertionargc==0' failed.,Program received signal SIGABRT, Aborted.and then the backtrace. Only the assertion from the gdb run is included, without the program name and before the signal line, so the server'scrashReport` parsing is not affected.capture_callstack=False: the result is the assertion message from the first run (without the program name), followed by the internal-error line.
- Without
-
I checked how
donate-cpu-server.pycrashReportparses this: it matches the signal line withline.find(' received signal ')and treats lines that start withcppcheck:as the version line. Neither check is set off by the inserted line.
Automated review of 4a34930 by Claude. The pull request was built and tested locally.
No description provided.