https://bugs.kde.org/show_bug.cgi?id=513403
Bug ID: 513403
Summary: Using relative paths for --suppressions and/or
--log-file breaks --trace-children
Classification: Developer tools
Product: valgrind
Version First 3.25.1
Reported In:
Platform: Arch Linux
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: memcheck
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
SUMMARY
I was running Valgrind tests for PostgreSQL and encountered a weird behavior
which I managed to reduce to the following:
When nvoking `pg_ctl` with:
```
valgrind ---trace-children=yes pg_ctl start -D ...
```
if we also supply `--suppressions` then depending on the path supplied being
relative or absolute certain syscalls will or will not fail. The syscalls that
do fail seem to be related to `exec(2)`. In my case both `execl` and `popen`
fail with `exit code 1`.
note:
When starting postgres via pg_ctl we do need the `trace-children`: `pg_ctl`
uses `exec` to start `postgres` binary which then uses `fork` to spawn multiple
process, including backends that serve individual client connections. So the
chain that breaks is `exec -> fork -> exec`
STEPS TO REPRODUCE
Here I build postgres from sources. The list of dependencies is relatively
short. See
https://wiki.postgresql.org/wiki/Compile_and_Install_from_source_code
```bash
#!/bin/env bash
# Build and initialize DB
mkdir -p /tmp/vg_repro
cd /tmp/vg_repro
git clone -b REL_18_STABLE --depth 1 --single-branch
https://git.postgresql.org/git/postgresql.git
cd postgresql/
./configure --enable-cassert --enable-debug CFLAGS='-ggdb -Og -g3
-fno-omit-frame-pointer -std=c99' --prefix=/tmp/vg_repro/pgbin
make -s -j8 && make -s install
export PATH=/tmp/vg_repro/pgbin/bin:$PATH
initdb /tmp/vg_repro/pgdata --encoding=UTF8 --locale=C --no-sync
cd /tmp/vg_repro
pg_ctl -D /tmp/vg_repro/pgdata -l logfile start
# Create a table we'll use later
psql -p 5432 postgres $USER -AXqtc "create table x(a text);"
pg_ctl -D /tmp/vg_repro/pgdata stop
# The working variant with absolute path:
valgrind --leak-check=no
--suppressions=$(pwd)/postgresql/src/tools/valgrind.supp --time-stamp=yes
--trace-children=yes pg_ctl start -D /tmp/vg_repro/pgdata
# Invoke COPY FROM PROGRAM (runs popen(2))
psql -p 5432 postgres $USER -AXqtc "copy x from program '/bin/true'"
#OK
# Same thing with relative path:
valgrind --leak-check=no --suppressions=postgresql/src/tools/valgrind.supp
--time-stamp=yes --trace-children=yes pg_ctl start -D /tmp/vg_repro/pgdata
psql -p 5432 postgres $USER -AXqtc "copy x from program '/bin/true'"
# ERROR: program "/bin/true" failed
# DETAIL: child process exited with exit code 1
# Don't forget to stop pg
pg_ctl -D /tmp/vg_repro/pgdata stop
```
OBSERVED RESULT
`exec`'d/`popen`'d target immediately exits with exit code 1.
EXPECTED RESULT
The target is executed normally regardless of absolute or relative paths being
used in the arguments.
ADDITIONAL INFORMATION
This behavior was first spotted on CI running Ubuntu, I believe it should be
present on most systems.
--
You are receiving this mail because:
You are watching all bug changes.