Debugging Rust SIGSEGV


#1

Hi,
I’m getting invalid memory references (sic!) when building packages using bindgen.
What is interesting RUST_BACKTRACE doesn’t show any backtrace.
I read cargo env variables and bindgen option for some debbuging but there is none.
Here is cargo build output

spock:~/kea-module$ RUST_BACKTRACE=1 cargo build
   Compiling kea-module v0.1.0 (file:///home/spock/kea-module)
error: failed to run custom build command for `kea-module v0.1.0 (file:///home/spock/kea-module)`
process didn't exit successfully: `/home/spock/kea-module/target/debug/build/kea-module-50631c877f7517a1/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
--- stdout
cargo:rustc-link-lib=kea-dhcpsrv
cargo:rustc-link-lib=kea-dhcp++
cargo:rustc-link-lib=kea-hooks
cargo:rustc-link-lib=kea-log

spock:~/kea-module$

Is there other methods to debug cargo so I can see what is wrong ?


#2

The easiest approach is probably to turn on core dumps and look at the dump in a debugger like GDB or LLDB: https://wiki.archlinux.org/index.php/Core_dump


#3

Problem is nothing is build.
I have nothing to analyze since I dont’ see any cargo/rust core dumps…


#4

Cargo and rust are not segfaulting. The build script of kea-module is:

process didn't exit successfully: `/home/spock/kea-module/target/debug/build/kea-module-50631c877f7517a1/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)

#5

You are right,
Those files are not build scripts, those are elf binaries (probably generated by bindgen).
Looks like bindgen problem not cargo itself.


#6

Those files are not build scripts, those are elf binaries (probably generated by bindgen).

Just to be clear here, a “build script” in a cargo project is a Rust binary that cargo compiles into a native binary and runs to do some work at build-time. Often these do things like generate Rust code (sometimes using bindgen), build C++ projects, or find native libraries to link against.

bindgen uses libclang, so it’s possible for it to cause crashes there.