Add notes about the c api and stacktraces to the guide

This commit is contained in:
konstin 2019-03-04 23:17:48 +01:00
parent 0866dd8989
commit 41ffe1ecdd
3 changed files with 17 additions and 0 deletions

View File

@ -8,5 +8,6 @@
- [Python Class](class.md)
- [Parallelism](parallelism.md)
- [Debugging](debugging.md)
- [Advanced Topics](advanced.md)
- [Building and Distribution](building-and-distribution.md)
- [Appendix: Pyo3 and rust-cpython](rust-cpython.md)

7
guide/src/advanced.md Normal file
View File

@ -0,0 +1,7 @@
# Advanced topics
## ffi
pyo3 exposes much of python's c api through the `ffi`.
The c api is naturually unsafe and requires you to manage reference counts, errors and specific invariants yourself. Please refer to the [C API Reference Manual](https://docs.python.org/3/c-api/) and [The Rustonomicon](https://doc.rust-lang.org/nightly/nomicon/ffi.html) before using any function from that api.

View File

@ -29,3 +29,12 @@ Activate an environment with the debug interpreter and recompile. If you're on l
[Download the suppressions file for cpython](https://raw.githubusercontent.com/python/cpython/master/Misc/valgrind-python.supp).
Run valgrind with `valgrind --suppressions=valgrind-python.supp ./my-command --with-options`
## Getting a stacktrace
The best start to investigate a crash such as an segmentation fault is a backtrace.
* Link against a debug build of python as described in the previous chapter
* Run `gdb <my-binary>`
* Enter `r` to run
* After the crash occured, enter `bt` or `bt full` to print the stacktrace