[Pkg-rust-maintainers] Bug#953648: bindgen: segfault on powerpc

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Mar 11 18:42:06 GMT 2020


Package: bindgen
Version: 0.51.1-4
X-Debbugs-Cc: Justus Winter <teythoon at avior.uberspace.de>
Control: affects -1 src:rust-nettle-sys

On perotto.debian.net (the powerpc porter box), i'm in a 32-bit powerpc
chroot experimenting with bindgen.

I get a segfault that i can't account for when trying to generate an
extremely minimal binding:

    void i_am_looking_at_the(void);


```
(sid_powerpc-dchroot)dkg at perotto:~/src/bindgen-test$ echo 'void i_am_looking_at_the(void);' > void.h
(sid_powerpc-dchroot)dkg at perotto:~/src/bindgen-test$ ulimit -c 10000000
(sid_powerpc-dchroot)dkg at perotto:~/src/bindgen-test$ bindgen void.h
Segmentation fault (core dumped)
(sid_powerpc-dchroot)dkg at perotto:~/src/bindgen-test$ gdb -c core $(which bindgen)
GNU gdb (Debian 9.1-2) 9.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/bindgen...
Reading symbols from /usr/lib/debug/.build-id/de/e00c8c6783edceb776638570fde91cededf1ba.debug...
[New LWP 41431]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/powerpc-linux-gnu/libthread_db.so.1".
bt
Core was generated by `bindgen void.h'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  strlen () at ../sysdeps/powerpc/powerpc32/strlen.S:98
98	../sysdeps/powerpc/powerpc32/strlen.S: No such file or directory.
warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file /usr/bin/bindgen.
Use `info auto-load python-scripts [REGEXP]' to list them.
(gdb) bt
#0  strlen () at ../sysdeps/powerpc/powerpc32/strlen.S:98
#1  0x00d337fc in std::ffi::c_str::CStr::from_ptr ()
#2  0x00b641a0 in bindgen::clang::cxstring_to_string_leaky (s=...) at src/clang.rs:1476
#3  bindgen::clang::cxstring_into_string (s=...) at src/clang.rs:1481
#4  bindgen::clang::extract_clang_version () at src/clang.rs:1925
#5  0x00ba14bc in bindgen::clang_version () at src/lib.rs:2121
#6  0x00aa2554 in bindgen::main () at src/main.rs:26
(gdb) up
#1  0x00d337fc in std::ffi::c_str::CStr::from_ptr ()
(gdb) up
#2  0x00b641a0 in bindgen::clang::cxstring_to_string_leaky (s=...) at src/clang.rs:1476
1476	    let c_str = unsafe { CStr::from_ptr(clang_getCString(s) as *const _) };
(gdb) print s
$1 = clang_sys::CXString {data: 0x143bef0, private_flags: 1}
(gdb) printf "%s\n", s.data
clang version 9.0.1-9 
(gdb) quit
(sid_powerpc-dchroot)dkg at perotto:~/src/bindgen-test$
```

Weirdly, i note that i see no arguments for strlen at all in the backtrace here :/

I don't know where to get the debug symbols for
std::ffi::c_str::CStr::from_ptr either.

I note that this has no problems running on x86-64.

Any suggestions are welcome!

I ran into this while debugging a failing powerpc build for nettle-sys,
which you can see here:

https://gitlab.com/sequoia-pgp/nettle-sys/-/issues/8

Regards,

         --dkg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 227 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-rust-maintainers/attachments/20200311/01f24ea4/attachment.sig>


More information about the Pkg-rust-maintainers mailing list