gtk-rs / gtk-rs-core

Rust bindings for GNOME libraries
https://gtk-rs.org/gtk-rs-core
MIT License
293 stars 115 forks source link

[BUG] glib-macros started regressing with rustc 1.82.0 on 32-bit arches #1554

Closed werdahias closed 3 weeks ago

werdahias commented 1 month ago

Bug description In Debian we enabled rustc to trigger the tests of crates which directly depend on it. glib-macros passed before but has regressed now on all 32-bit arches.

Backtrace

 running 12 tests
379s test derive_enum ... ok
379s test derive_boxed_nullable ... ok
379s test derive_boxed ... ok
379s test attr_flags_with_default ... ok
379s test attr_flags ... ok
379s thread 'boxed_transparent_ptr' panicked at core/src/panicking.rs:221:5:
379s unsafe precondition(s) violated: Layout::from_size_align_unchecked requires that align is a power of 2 and the rounded-up allocation size does not exceed isize::MAX
379s stack backtrace:
379s    0: rust_begin_unwind
379s              at /usr/src/rustc-1.82.0/library/std/src/panicking.rs:662:5
379s    1: core::panicking::panic_nounwind_fmt::runtime
379s              at /usr/src/rustc-1.82.0/library/core/src/panicking.rs:112:18
379s    2: core::panicking::panic_nounwind_fmt
379s              at /usr/src/rustc-1.82.0/library/core/src/panicking.rs:122:5
379s    3: core::panicking::panic_nounwind
379s              at /usr/src/rustc-1.82.0/library/core/src/panicking.rs:221:5
379s    4: core::alloc::layout::Layout::from_size_align_unchecked::precondition_check
379s              at /usr/src/rustc-1.82.0/library/core/src/ub_checks.rs:70:21
379s    5: core::alloc::layout::Layout::from_size_align_unchecked
379s              at /usr/src/rustc-1.82.0/library/core/src/ub_checks.rs:77:17
379s    6: alloc::raw_vec::RawVecInner<A>::current_memory
379s              at /usr/src/rustc-1.82.0/library/alloc/src/raw_vec.rs:534:30
379s    7: alloc::raw_vec::RawVecInner<A>::deallocate
379s              at /usr/src/rustc-1.82.0/library/alloc/src/raw_vec.rs:749:38
379s    8: <alloc::raw_vec::RawVec<T,A> as core::ops::drop::Drop>::drop
379s              at /usr/src/rustc-1.82.0/library/alloc/src/raw_vec.rs:409:18
379s    9: core::ptr::drop_in_place<alloc::raw_vec::RawVec<u8>>
379s              at /usr/src/rustc-1.82.0/library/core/src/ptr/mod.rs:574:1
379s   10: core::ptr::drop_in_place<alloc::vec::Vec<u8>>
379s              at /usr/src/rustc-1.82.0/library/core/src/ptr/mod.rs:574:1
379s   11: core::ptr::drop_in_place<alloc::string::String>
379s              at /usr/src/rustc-1.82.0/library/core/src/ptr/mod.rs:574:1
379s   12: core::ptr::drop_in_place<test::boxed_transparent_ptr::MyBoxed>
379s              at /usr/src/rustc-1.82.0/library/core/src/ptr/mod.rs:574:1
379s   13: <glib::collections::ptr_slice::PtrSlice<T> as core::ops::drop::Drop>::drop
379s              at /usr/share/cargo/registry/glib-0.20.4/src/collections/ptr_slice.rs:88:21
379s   14: core::ptr::drop_in_place<glib::collections::ptr_slice::PtrSlice<test::boxed_transparent_ptr::MyBoxed>>
379s              at /usr/src/rustc-1.82.0/library/core/src/ptr/mod.rs:574:1
379s   15: test::boxed_transparent_ptr
379s              at ./tests/test.rs:201:1
379s   16: test::boxed_transparent_ptr::{{closure}}
379s              at ./tests/test.rs:188:27
379s   17: core::ops::function::FnOnce::call_once
379s              at /usr/src/rustc-1.82.0/library/core/src/ops/function.rs:250:5
379s   18: core::ops::function::FnOnce::call_once
379s              at /usr/src/rustc-1.82.0/library/core/src/ops/function.rs:250:5
379s note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
379s thread caused non-unwinding panic. aborting.
379s error: test failed, to rerun pass `--test test`
379s 
379s Caused by:
379s   process didn't exit successfully: `CARGO=/usr/bin/cargo CARGO_MANIFEST_DIR=/usr/share/cargo/registry/glib-macros-0.20.4 CARGO_PKG_AUTHORS='The gtk-rs Project Developers' CARGO_PKG_DESCRIPTION='Rust bindings for the GLib library, proc macros crate' CARGO_PKG_HOMEPAGE='https://gtk-rs.org/' CARGO_PKG_LICENSE=MIT CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=glib-macros CARGO_PKG_README='' CARGO_PKG_REPOSITORY='https://github.com/gtk-rs/gtk-rs-core' CARGO_PKG_RUST_VERSION=1.70 CARGO_PKG_VERSION=0.20.4 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=20 CARGO_PKG_VERSION_PATCH=4 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/tmp/tmp.WqOM0yNRWD/target/armv5te-unknown-linux-gnueabi/debug/deps:/tmp/tmp.WqOM0yNRWD/target/armv5te-unknown-linux-gnueabi/debug:/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib' /tmp/tmp.WqOM0yNRWD/target/armv5te-unknown-linux-gnueabi/debug/deps/test-24e18340500445a5` (signal: 6, SIGABRT: process abort signal)
sdroege commented 1 month ago

Exciting, this only seems to happen on 32 bit ARM or so. Can't reproduce this here. I'll take a look later what could be the problem

sdroege commented 1 month ago

@werdahias Does this also happen on other 32 bit architectures, or other 32 bit ARM? This is armv5te which IIRC is armel in Debian terms. How did it behave on armhf?

I can't see anything obviously wrong in the code, so if it only fails on armel it might very well be a toolchain bug.

Fabian-Gruenbichler commented 4 weeks ago

the test fails on armel, armhf and i386, so it seems very likely that it is 32-bit related: https://ci.debian.net/packages/r/rust-glib-macros/testing/i386/53651276/#L9055

I did a quick manual test and just that test case panics on i386 when executed manually using cargo test. I didn't verify whether it just affects Debian's toolchain, or upstream's 1.82 as well.

sdroege commented 4 weeks ago

Thanks, I'll give that a try on 32 bit x86 later.

sdroege commented 4 weeks ago

I can reproduce it with the 1.82 toolchain from rustup with the i686-unknown-linux-gnu target too

sdroege commented 4 weeks ago

Found the problem

sdroege commented 3 weeks ago

84c951ef5a62 was simply wrong. Derived Boxed types are not TransparentPtrType (== equivalent to a pointer of their FFI representation), they're TransparentType (== equivalent to their FFI representation).

See https://github.com/gtk-rs/gtk-rs-core/pull/1559

Fabian-Gruenbichler commented 3 weeks ago

thanks for the quick fix!

@werdahias I'll do another upload of 1.82 soonish, so the migration age counter will start over anyway, but it would be great if we could get this fixed in Debian quickly as well since it seems to be the main remaining blocker/regression for 1.82 :)

sdroege commented 3 weeks ago

You can also update to 0.20.5 instead of backporting the patch