donate_cpu_lib.py: Fix that timed out analyses are handled as crashes (#2561)

Sometimes it could happen that SIGSEGV is thrown when Cppcheck is killed
because of a timeout. Then the execution is wrongly handled as a crash
and debugged with gdb instead of marking it as timed out.
This fixes that issue by checking the time out before checking sig_num.
This commit is contained in:
Sebastian 2020-02-28 08:12:10 +01:00 committed by GitHub
parent f0e3f9e79a
commit feb767a66b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -15,7 +15,7 @@ import shlex
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/ # Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic # Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
# changes) # changes)
CLIENT_VERSION = "1.2.3" CLIENT_VERSION = "1.2.4"
# Timeout for analysis with Cppcheck in seconds # Timeout for analysis with Cppcheck in seconds
CPPCHECK_TIMEOUT = 60 * 60 CPPCHECK_TIMEOUT = 60 * 60
@ -292,6 +292,9 @@ def scan_package(work_path, cppcheck_path, jobs, libraries):
sig_start_pos = sig_pos + len(sig_msg) sig_start_pos = sig_pos + len(sig_msg)
sig_num = int(stderr[sig_start_pos:stderr.find(' ', sig_start_pos)]) sig_num = int(stderr[sig_start_pos:stderr.find(' ', sig_start_pos)])
print('cppcheck finished with ' + str(returncode) + ('' if sig_num == -1 else ' (signal ' + str(sig_num) + ')')) print('cppcheck finished with ' + str(returncode) + ('' if sig_num == -1 else ' (signal ' + str(sig_num) + ')'))
if returncode == RETURN_CODE_TIMEOUT:
print('Timeout!')
return returncode, stdout, '', elapsed_time, options, ''
# generate stack trace for SIGSEGV, SIGABRT, SIGILL, SIGFPE, SIGBUS # generate stack trace for SIGSEGV, SIGABRT, SIGILL, SIGFPE, SIGBUS
if returncode in (-11, -6, -4, -8, -7) or sig_num in (11, 6, 4, 8, 7): if returncode in (-11, -6, -4, -8, -7) or sig_num in (11, 6, 4, 8, 7):
print('Crash!') print('Crash!')
@ -308,9 +311,6 @@ def scan_package(work_path, cppcheck_path, jobs, libraries):
else: else:
stacktrace = stdout[last_check_pos:] stacktrace = stdout[last_check_pos:]
return returncode, stacktrace, '', returncode, options, '' return returncode, stacktrace, '', returncode, options, ''
if returncode == RETURN_CODE_TIMEOUT:
print('Timeout!')
return returncode, stdout, '', elapsed_time, options, ''
if returncode != 0: if returncode != 0:
print('Error!') print('Error!')
if returncode > 0: if returncode > 0: