Fix #9584: Limit stack trace depth in daca@home crash page (#2502)

This limits the backtrace to a maximum of 50 entries.
Trac ticket: https://trac.cppcheck.net/ticket/9584
This commit is contained in:
Sebastian 2020-01-25 15:20:06 +01:00 committed by GitHub
parent 0bab9ba6e3
commit 206eb0f527
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -8,12 +8,13 @@ import socket
import time import time
import re import re
import tarfile import tarfile
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.0" CLIENT_VERSION = "1.2.1"
# Timeout for analysis with Cppcheck in seconds # Timeout for analysis with Cppcheck in seconds
CPPCHECK_TIMEOUT = 60 * 60 CPPCHECK_TIMEOUT = 60 * 60
@ -254,7 +255,7 @@ def has_include(path, includes):
def run_command(cmd): def run_command(cmd):
print(cmd) print(cmd)
startTime = time.time() startTime = time.time()
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try: try:
comm = p.communicate(timeout=CPPCHECK_TIMEOUT) comm = p.communicate(timeout=CPPCHECK_TIMEOUT)
return_code = p.returncode return_code = p.returncode
@ -302,7 +303,7 @@ def scan_package(work_path, cppcheck_path, jobs, libraries):
stacktrace = '' stacktrace = ''
if cppcheck_path == 'cppcheck': if cppcheck_path == 'cppcheck':
# re-run within gdb to get a stacktrace # re-run within gdb to get a stacktrace
cmd = 'gdb --batch --eval-command=run --eval-command=bt --return-child-result --args ' + cppcheck_cmd + " -j1" cmd = 'gdb --batch --eval-command=run --eval-command="bt 50" --return-child-result --args ' + cppcheck_cmd + " -j1"
dummy, stdout, stderr, elapsed_time = run_command(cmd) dummy, stdout, stderr, elapsed_time = run_command(cmd)
gdb_pos = stdout.find(" received signal") gdb_pos = stdout.find(" received signal")
if not gdb_pos == -1: if not gdb_pos == -1: