Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions cli/threadexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ int ThreadExecutor::handleRead(int rpipe, unsigned int &result)
}

if (type != REPORT_OUT && type != REPORT_ERROR && type != REPORT_INFO && type != CHILD_END) {
std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl;
std::cerr << "#### ThreadExecutor::handleRead error, type was:" << type << std::endl;
std::exit(0);
}

unsigned int len = 0;
if (read(rpipe, &len, sizeof(len)) <= 0) {
std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl;
std::cerr << "#### ThreadExecutor::handleRead error, type was:" << type << std::endl;
std::exit(0);
}

Expand All @@ -106,7 +106,7 @@ int ThreadExecutor::handleRead(int rpipe, unsigned int &result)
char *buf = new char[len + 1];
const ssize_t readIntoBuf = read(rpipe, buf, len);
if (readIntoBuf <= 0) {
std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl;
std::cerr << "#### ThreadExecutor::handleRead error, type was:" << type << std::endl;
std::exit(0);
}
buf[readIntoBuf] = 0;
Expand Down Expand Up @@ -183,25 +183,25 @@ unsigned int ThreadExecutor::check()
if ((iFile != _files.end() || iFileSettings != _settings.project.fileSettings.end()) && nchildren < _settings.jobs && checkLoadAverage(nchildren)) {
int pipes[2];
if (pipe(pipes) == -1) {
std::cerr << "pipe() failed: "<< std::strerror(errno) << std::endl;
std::cerr << "#### ThreadExecutor::check, pipe() failed: "<< std::strerror(errno) << std::endl;
std::exit(EXIT_FAILURE);
}

int flags = 0;
if ((flags = fcntl(pipes[0], F_GETFL, 0)) < 0) {
std::cerr << "fcntl(F_GETFL) failed: "<< std::strerror(errno) << std::endl;
std::cerr << "#### ThreadExecutor::check, fcntl(F_GETFL) failed: "<< std::strerror(errno) << std::endl;
std::exit(EXIT_FAILURE);
}

if (fcntl(pipes[0], F_SETFL, flags | O_NONBLOCK) < 0) {
std::cerr << "fcntl(F_SETFL) failed: "<< std::strerror(errno) << std::endl;
std::cerr << "#### ThreadExecutor::check, fcntl(F_SETFL) failed: "<< std::strerror(errno) << std::endl;
std::exit(EXIT_FAILURE);
}

pid_t pid = fork();
if (pid < 0) {
// Error
std::cerr << "Failed to create child process: "<< std::strerror(errno) << std::endl;
std::cerr << "#### ThreadExecutor::check, Failed to create child process: "<< std::strerror(errno) << std::endl;
std::exit(EXIT_FAILURE);
} else if (pid == 0) {
close(pipes[0]);
Expand Down Expand Up @@ -377,18 +377,18 @@ unsigned int ThreadExecutor::check()
for (unsigned int i = 0; i < _settings.jobs; ++i) {
threadHandles[i] = (HANDLE)_beginthreadex(nullptr, 0, threadProc, this, 0, nullptr);
if (!threadHandles[i]) {
std::cerr << "#### .\nThreadExecutor::check error, errno :" << errno << std::endl;
std::cerr << "#### ThreadExecutor::check error, errno :" << errno << std::endl;
exit(EXIT_FAILURE);
}
}

const DWORD waitResult = WaitForMultipleObjects(_settings.jobs, threadHandles, TRUE, INFINITE);
if (waitResult != WAIT_OBJECT_0) {
if (waitResult == WAIT_FAILED) {
std::cerr << "#### .\nThreadExecutor::check wait failed, result: " << waitResult << " error: " << GetLastError() << std::endl;
std::cerr << "#### ThreadExecutor::check wait failed, result: " << waitResult << " error: " << GetLastError() << std::endl;
exit(EXIT_FAILURE);
} else {
std::cerr << "#### .\nThreadExecutor::check wait failed, result: " << waitResult << std::endl;
std::cerr << "#### ThreadExecutor::check wait failed, result: " << waitResult << std::endl;
exit(EXIT_FAILURE);
}
}
Expand All @@ -398,14 +398,14 @@ unsigned int ThreadExecutor::check()
DWORD exitCode;

if (!GetExitCodeThread(threadHandles[i], &exitCode)) {
std::cerr << "#### .\nThreadExecutor::check get exit code failed, error:" << GetLastError() << std::endl;
std::cerr << "#### ThreadExecutor::check get exit code failed, error:" << GetLastError() << std::endl;
exit(EXIT_FAILURE);
}

result += exitCode;

if (!CloseHandle(threadHandles[i])) {
std::cerr << "#### .\nThreadExecutor::check close handle failed, error:" << GetLastError() << std::endl;
std::cerr << "#### ThreadExecutor::check close handle failed, error:" << GetLastError() << std::endl;
exit(EXIT_FAILURE);
}
}
Expand Down
19 changes: 16 additions & 3 deletions tools/donate-cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# 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
# changes)
CLIENT_VERSION = "1.1.17"
CLIENT_VERSION = "1.1.18"


def checkRequirements():
Expand Down Expand Up @@ -274,8 +274,8 @@ def scanPackage(workPath, cppcheckPath, jobs):
cppcheck_cmd = cppcheckPath + '/cppcheck' + ' ' + options
cmd = 'nice ' + cppcheck_cmd
returncode, stdout, stderr, elapsedTime = runCommand(cmd)
print('cppcheck finished with ' + str(returncode))
if returncode == -11 or stderr.find('Internal error: Child process crashed with signal 11 [cppcheckError]') > 0:
# Crash!
print('Crash!')
stacktrace = ''
if cppcheckPath == 'cppcheck':
Expand All @@ -289,7 +289,20 @@ def scanPackage(workPath, cppcheckPath, jobs):
stacktrace = stdout[gdb_pos:]
else:
stacktrace = stdout[last_check_pos:]
return -1, stacktrace, '', -1, options
return -11, stacktrace, '', -11, options
if returncode != 0:
print('Error!')
return returncode, '', '', returncode, options
if stderr.find('Internal error: Child process crashed with signal ') > 0:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those greps require an English language environment?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It#s the same string, that was already used in the crash detection and is written exactly like this by cppcheck, so there should be locale issues.

print('Error!')
s = 'Internal error: Child process crashed with signal '
pos1 = stderr.find(s)
pos2 = stderr.find(' [cppcheckError]', pos1)
signr = int(stderr[pos1+len(s):pos2])
return -signr, '', '', -signr, options
if stderr.find('#### ThreadExecutor') > 0:
print('Thread!')
return -111, '', '', -111, options
information_messages_list = []
issue_messages_list = []
count = 0
Expand Down