Skip to content

Commit 1231338

Browse files
committed
doc: test: unittest segfault gdb
Feedback from Jon Atack and Marco Falke.
1 parent f66ecea commit 1231338

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/test/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,29 @@ start debugging, just like you would with any other program:
7474
```bash
7575
gdb src/test/test_bitcoin
7676
```
77+
78+
#### Segmentation faults
79+
80+
If you hit a segmentation fault during a test run, you can diagnose where the fault
81+
is happening by running `gdb ./src/test/test_bitcoin` and then using the `bt` command
82+
within gdb.
83+
84+
Another tool that can be used to resolve segmentation faults is
85+
[valgrind](https://valgrind.org/).
86+
87+
If for whatever reason you want to produce a core dump file for this fault, you can do
88+
that as well. By default, the boost test runner will intercept system errors and not
89+
produce a core file. To bypass this, add `--catch_system_errors=no` to the
90+
`test_bitcoin` arguments and ensure that your ulimits are set properly (e.g. `ulimit -c
91+
unlimited`).
92+
93+
Running the tests and hitting a segmentation fault should now produce a file called `core`
94+
(on Linux platforms, the file name will likely depend on the contents of
95+
`/proc/sys/kernel/core_pattern`).
96+
97+
You can then explore the core dump using
98+
``` bash
99+
gdb src/test/test_bitcoin core
100+
101+
(gbd) bt # produce a backtrace for where a segfault occurred
102+
```

0 commit comments

Comments
 (0)