Skip to content
Open
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
11 changes: 9 additions & 2 deletions Tools/autotest/pysim/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,9 +714,16 @@ def start_SITL(binary,

first = cmd[0]
rest = cmd[1:]
spawn_env = None
spawn_env = dict(os.environ)
# Tell SITL where to find dumpstack.sh and dumpcore.sh. It looks
# for them relative to its working directory, which works for a
# serial run - that runs in the repo root - but not under
# --parallel, where each instance runs in its own directory and
# every lookup misses. A panic there produces no backtrace at
# all, which is exactly when one is wanted.
spawn_env.setdefault('AP_SCRIPTS_DIR_PATH',
os.path.abspath(reltopdir('Tools/scripts')))
if asan:
spawn_env = dict(os.environ)
log_base = asan_log_filepath(binary=binary, model=model)
existing = spawn_env.get('ASAN_OPTIONS', '')
# Append our options after any inherited ones so that our
Expand Down
17 changes: 14 additions & 3 deletions libraries/AP_HAL_SITL/system.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <stdarg.h>
#include <limits.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
Expand Down Expand Up @@ -75,14 +76,22 @@ static void run_command_on_ownpid(const char *commandname)
"APM/Tools/scripts/%s", // for autotest server
"../Tools/scripts/%s", // when run from e.g. ArduCopter subdirectory
};
char buffer[60];
// long enough for an absolute path from AP_SCRIPTS_DIR_PATH; the 60
// bytes this used to be was not - a checkout under a path of any
// length silently truncated, and the truncated name simply failed to
// stat, so the override looked as though it had been ignored
char buffer[PATH_MAX];
for (uint8_t i=0; i<ARRAY_SIZE(paths); i++) {
if (paths[i] == nullptr) {
continue;
}
// form up a filepath from each path and commandname; if it
// exists, use it
snprintf(buffer, sizeof(buffer), paths[i], commandname);
const int len = snprintf(buffer, sizeof(buffer), paths[i], commandname);
if (len < 0 || (unsigned)len >= sizeof(buffer)) {
// truncated, so this is not the path we were asked for
continue;
}
if (::stat(buffer, &statbuf) != -1) {
command_filepath = buffer;
break;
Expand Down Expand Up @@ -112,7 +121,9 @@ static void run_command_on_ownpid(const char *commandname)
commandname,
p+1,
(int)getpid());
char cmd[200];
// must fit the command filepath found above, which may now be
// an absolute path, plus the output filepath
char cmd[PATH_MAX + sizeof(output_filepath) + 32];
snprintf(cmd,
sizeof(cmd),
"sh %s %d >%s 2>&1",
Expand Down
Loading