archlinux / alpm.rs

Rust bindings for libalpm
GNU General Public License v3.0
112 stars 21 forks source link

Segfault when dropping Alpm after calling Db::groups() #31

Closed brokenbyte closed 1 year ago

brokenbyte commented 1 year ago

Minimal reproducible example:

#![allow(unused)]
fn main() {
    let conf = pacmanconf::Config::new().unwrap();
    let mut alpm = alpm::Alpm::new2(&conf.root_dir, &conf.db_path).unwrap();
    alpm_utils::configure_alpm(&mut alpm, &conf).unwrap();
    alpm::Alpm::new(conf.root_dir, conf.db_path)
        .unwrap()
        .localdb()
        .groups();
}

Dependencies: cargo add pacmanconf alpm alpm_utils

GDB backtrace: image

Valgrind Output ```text ==107909== Memcheck, a memory error detector ==107909== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al. ==107909== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info ==107909== Command: ./target/debug/segfault ==107909== ==107909== Invalid read of size 8 ==107909== at 0x486DA46: free_groupcache (db.c:494) ==107909== by 0x486DB6C: _alpm_db_free_pkgcache (db.c:517) ==107909== by 0x486D166: _alpm_db_free (db.c:329) ==107909== by 0x486C57D: _alpm_db_unregister (db.c:75) ==107909== by 0x485E409: alpm_release (alpm.c:106) ==107909== by 0x118693: ::drop (alpm.rs:33) ==107909== by 0x1180C6: core::ptr::drop_in_place (mod.rs:490) ==107909== by 0x1152FA: segfault::main (main.rs:9) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== Address 0x58e5620 is 0 bytes inside a block of size 24 free'd ==107909== at 0x484426F: free (vg_replace_malloc.c:884) ==107909== by 0x485E4DA: alpm_list_free (alpm_list.c:42) ==107909== by 0x11494A: as core::ops::drop::Drop>::drop (list.rs:250) ==107909== by 0x1148F9: core::ptr::drop_in_place> (mod.rs:490) ==107909== by 0x114860: core::ptr::drop_in_place,alpm::error::Error>> (mod.rs:490) ==107909== by 0x1152E7: segfault::main (main.rs:9) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== by 0x114A69: std::rt::lang_start (rt.rs:165) ==107909== by 0x11585D: main (in /home/user/tmp/rust/segfault/target/debug/segfault) ==107909== Block was alloc'd at ==107909== at 0x4841888: malloc (vg_replace_malloc.c:393) ==107909== by 0x485E583: alpm_list_append (alpm_list.c:74) ==107909== by 0x485E563: alpm_list_add (alpm_list.c:66) ==107909== by 0x486E119: load_grpcache (db.c:669) ==107909== by 0x486E215: _alpm_db_get_groupcache (db.c:688) ==107909== by 0x486CF3F: alpm_db_get_groupcache (db.c:281) ==107909== by 0x119D5C: alpm::db::Db::groups (db.rs:153) ==107909== by 0x1152D8: segfault::main (main.rs:6) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== ==107909== Invalid write of size 8 ==107909== at 0x486DA55: free_groupcache (db.c:495) ==107909== by 0x486DB6C: _alpm_db_free_pkgcache (db.c:517) ==107909== by 0x486D166: _alpm_db_free (db.c:329) ==107909== by 0x486C57D: _alpm_db_unregister (db.c:75) ==107909== by 0x485E409: alpm_release (alpm.c:106) ==107909== by 0x118693: ::drop (alpm.rs:33) ==107909== by 0x1180C6: core::ptr::drop_in_place (mod.rs:490) ==107909== by 0x1152FA: segfault::main (main.rs:9) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== Address 0x58e5620 is 0 bytes inside a block of size 24 free'd ==107909== at 0x484426F: free (vg_replace_malloc.c:884) ==107909== by 0x485E4DA: alpm_list_free (alpm_list.c:42) ==107909== by 0x11494A: as core::ops::drop::Drop>::drop (list.rs:250) ==107909== by 0x1148F9: core::ptr::drop_in_place> (mod.rs:490) ==107909== by 0x114860: core::ptr::drop_in_place,alpm::error::Error>> (mod.rs:490) ==107909== by 0x1152E7: segfault::main (main.rs:9) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== by 0x114A69: std::rt::lang_start (rt.rs:165) ==107909== by 0x11585D: main (in /home/user/tmp/rust/segfault/target/debug/segfault) ==107909== Block was alloc'd at ==107909== at 0x4841888: malloc (vg_replace_malloc.c:393) ==107909== by 0x485E583: alpm_list_append (alpm_list.c:74) ==107909== by 0x485E563: alpm_list_add (alpm_list.c:66) ==107909== by 0x486E119: load_grpcache (db.c:669) ==107909== by 0x486E215: _alpm_db_get_groupcache (db.c:688) ==107909== by 0x486CF3F: alpm_db_get_groupcache (db.c:281) ==107909== by 0x119D5C: alpm::db::Db::groups (db.rs:153) ==107909== by 0x1152D8: segfault::main (main.rs:6) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== ==107909== Invalid read of size 8 ==107909== at 0x486DA60: free_groupcache (db.c:493) ==107909== by 0x486DB6C: _alpm_db_free_pkgcache (db.c:517) ==107909== by 0x486D166: _alpm_db_free (db.c:329) ==107909== by 0x486C57D: _alpm_db_unregister (db.c:75) ==107909== by 0x485E409: alpm_release (alpm.c:106) ==107909== by 0x118693: ::drop (alpm.rs:33) ==107909== by 0x1180C6: core::ptr::drop_in_place (mod.rs:490) ==107909== by 0x1152FA: segfault::main (main.rs:9) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== Address 0x58e5630 is 16 bytes inside a block of size 24 free'd ==107909== at 0x484426F: free (vg_replace_malloc.c:884) ==107909== by 0x485E4DA: alpm_list_free (alpm_list.c:42) ==107909== by 0x11494A: as core::ops::drop::Drop>::drop (list.rs:250) ==107909== by 0x1148F9: core::ptr::drop_in_place> (mod.rs:490) ==107909== by 0x114860: core::ptr::drop_in_place,alpm::error::Error>> (mod.rs:490) ==107909== by 0x1152E7: segfault::main (main.rs:9) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== by 0x114A69: std::rt::lang_start (rt.rs:165) ==107909== by 0x11585D: main (in /home/user/tmp/rust/segfault/target/debug/segfault) ==107909== Block was alloc'd at ==107909== at 0x4841888: malloc (vg_replace_malloc.c:393) ==107909== by 0x485E583: alpm_list_append (alpm_list.c:74) ==107909== by 0x485E563: alpm_list_add (alpm_list.c:66) ==107909== by 0x486E119: load_grpcache (db.c:669) ==107909== by 0x486E215: _alpm_db_get_groupcache (db.c:688) ==107909== by 0x486CF3F: alpm_db_get_groupcache (db.c:281) ==107909== by 0x119D5C: alpm::db::Db::groups (db.rs:153) ==107909== by 0x1152D8: segfault::main (main.rs:6) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== ==107909== Invalid read of size 8 ==107909== at 0x485E513: alpm_list_free_inner (alpm_list.c:53) ==107909== by 0x486DA88: free_groupcache (db.c:497) ==107909== by 0x486DB6C: _alpm_db_free_pkgcache (db.c:517) ==107909== by 0x486D166: _alpm_db_free (db.c:329) ==107909== by 0x486C57D: _alpm_db_unregister (db.c:75) ==107909== by 0x485E409: alpm_release (alpm.c:106) ==107909== by 0x118693: ::drop (alpm.rs:33) ==107909== by 0x1180C6: core::ptr::drop_in_place (mod.rs:490) ==107909== by 0x1152FA: segfault::main (main.rs:9) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== Address 0x58e5620 is 0 bytes inside a block of size 24 free'd ==107909== at 0x484426F: free (vg_replace_malloc.c:884) ==107909== by 0x485E4DA: alpm_list_free (alpm_list.c:42) ==107909== by 0x11494A: as core::ops::drop::Drop>::drop (list.rs:250) ==107909== by 0x1148F9: core::ptr::drop_in_place> (mod.rs:490) ==107909== by 0x114860: core::ptr::drop_in_place,alpm::error::Error>> (mod.rs:490) ==107909== by 0x1152E7: segfault::main (main.rs:9) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== by 0x114A69: std::rt::lang_start (rt.rs:165) ==107909== by 0x11585D: main (in /home/user/tmp/rust/segfault/target/debug/segfault) ==107909== Block was alloc'd at ==107909== at 0x4841888: malloc (vg_replace_malloc.c:393) ==107909== by 0x485E583: alpm_list_append (alpm_list.c:74) ==107909== by 0x485E563: alpm_list_add (alpm_list.c:66) ==107909== by 0x486E119: load_grpcache (db.c:669) ==107909== by 0x486E215: _alpm_db_get_groupcache (db.c:688) ==107909== by 0x486CF3F: alpm_db_get_groupcache (db.c:281) ==107909== by 0x119D5C: alpm::db::Db::groups (db.rs:153) ==107909== by 0x1152D8: segfault::main (main.rs:6) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== ==107909== Invalid read of size 8 ==107909== at 0x485E52F: alpm_list_free_inner (alpm_list.c:56) ==107909== by 0x486DA88: free_groupcache (db.c:497) ==107909== by 0x486DB6C: _alpm_db_free_pkgcache (db.c:517) ==107909== by 0x486D166: _alpm_db_free (db.c:329) ==107909== by 0x486C57D: _alpm_db_unregister (db.c:75) ==107909== by 0x485E409: alpm_release (alpm.c:106) ==107909== by 0x118693: ::drop (alpm.rs:33) ==107909== by 0x1180C6: core::ptr::drop_in_place (mod.rs:490) ==107909== by 0x1152FA: segfault::main (main.rs:9) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== Address 0x58e5630 is 16 bytes inside a block of size 24 free'd ==107909== at 0x484426F: free (vg_replace_malloc.c:884) ==107909== by 0x485E4DA: alpm_list_free (alpm_list.c:42) ==107909== by 0x11494A: as core::ops::drop::Drop>::drop (list.rs:250) ==107909== by 0x1148F9: core::ptr::drop_in_place> (mod.rs:490) ==107909== by 0x114860: core::ptr::drop_in_place,alpm::error::Error>> (mod.rs:490) ==107909== by 0x1152E7: segfault::main (main.rs:9) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== by 0x114A69: std::rt::lang_start (rt.rs:165) ==107909== by 0x11585D: main (in /home/user/tmp/rust/segfault/target/debug/segfault) ==107909== Block was alloc'd at ==107909== at 0x4841888: malloc (vg_replace_malloc.c:393) ==107909== by 0x485E583: alpm_list_append (alpm_list.c:74) ==107909== by 0x485E563: alpm_list_add (alpm_list.c:66) ==107909== by 0x486E119: load_grpcache (db.c:669) ==107909== by 0x486E215: _alpm_db_get_groupcache (db.c:688) ==107909== by 0x486CF3F: alpm_db_get_groupcache (db.c:281) ==107909== by 0x119D5C: alpm::db::Db::groups (db.rs:153) ==107909== by 0x1152D8: segfault::main (main.rs:6) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== ==107909== Invalid read of size 8 ==107909== at 0x485E4C7: alpm_list_free (alpm_list.c:41) ==107909== by 0x486DA98: free_groupcache (db.c:497) ==107909== by 0x486DB6C: _alpm_db_free_pkgcache (db.c:517) ==107909== by 0x486D166: _alpm_db_free (db.c:329) ==107909== by 0x486C57D: _alpm_db_unregister (db.c:75) ==107909== by 0x485E409: alpm_release (alpm.c:106) ==107909== by 0x118693: ::drop (alpm.rs:33) ==107909== by 0x1180C6: core::ptr::drop_in_place (mod.rs:490) ==107909== by 0x1152FA: segfault::main (main.rs:9) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== Address 0x58e5630 is 16 bytes inside a block of size 24 free'd ==107909== at 0x484426F: free (vg_replace_malloc.c:884) ==107909== by 0x485E4DA: alpm_list_free (alpm_list.c:42) ==107909== by 0x11494A: as core::ops::drop::Drop>::drop (list.rs:250) ==107909== by 0x1148F9: core::ptr::drop_in_place> (mod.rs:490) ==107909== by 0x114860: core::ptr::drop_in_place,alpm::error::Error>> (mod.rs:490) ==107909== by 0x1152E7: segfault::main (main.rs:9) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== by 0x114A69: std::rt::lang_start (rt.rs:165) ==107909== by 0x11585D: main (in /home/user/tmp/rust/segfault/target/debug/segfault) ==107909== Block was alloc'd at ==107909== at 0x4841888: malloc (vg_replace_malloc.c:393) ==107909== by 0x485E583: alpm_list_append (alpm_list.c:74) ==107909== by 0x485E563: alpm_list_add (alpm_list.c:66) ==107909== by 0x486E119: load_grpcache (db.c:669) ==107909== by 0x486E215: _alpm_db_get_groupcache (db.c:688) ==107909== by 0x486CF3F: alpm_db_get_groupcache (db.c:281) ==107909== by 0x119D5C: alpm::db::Db::groups (db.rs:153) ==107909== by 0x1152D8: segfault::main (main.rs:6) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== ==107909== Invalid free() / delete / delete[] / realloc() ==107909== at 0x484426F: free (vg_replace_malloc.c:884) ==107909== by 0x485E4DA: alpm_list_free (alpm_list.c:42) ==107909== by 0x486DA98: free_groupcache (db.c:497) ==107909== by 0x486DB6C: _alpm_db_free_pkgcache (db.c:517) ==107909== by 0x486D166: _alpm_db_free (db.c:329) ==107909== by 0x486C57D: _alpm_db_unregister (db.c:75) ==107909== by 0x485E409: alpm_release (alpm.c:106) ==107909== by 0x118693: ::drop (alpm.rs:33) ==107909== by 0x1180C6: core::ptr::drop_in_place (mod.rs:490) ==107909== by 0x1152FA: segfault::main (main.rs:9) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== Address 0x58e5620 is 0 bytes inside a block of size 24 free'd ==107909== at 0x484426F: free (vg_replace_malloc.c:884) ==107909== by 0x485E4DA: alpm_list_free (alpm_list.c:42) ==107909== by 0x11494A: as core::ops::drop::Drop>::drop (list.rs:250) ==107909== by 0x1148F9: core::ptr::drop_in_place> (mod.rs:490) ==107909== by 0x114860: core::ptr::drop_in_place,alpm::error::Error>> (mod.rs:490) ==107909== by 0x1152E7: segfault::main (main.rs:9) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== by 0x114A69: std::rt::lang_start (rt.rs:165) ==107909== by 0x11585D: main (in /home/user/tmp/rust/segfault/target/debug/segfault) ==107909== Block was alloc'd at ==107909== at 0x4841888: malloc (vg_replace_malloc.c:393) ==107909== by 0x485E583: alpm_list_append (alpm_list.c:74) ==107909== by 0x485E563: alpm_list_add (alpm_list.c:66) ==107909== by 0x486E119: load_grpcache (db.c:669) ==107909== by 0x486E215: _alpm_db_get_groupcache (db.c:688) ==107909== by 0x486CF3F: alpm_db_get_groupcache (db.c:281) ==107909== by 0x119D5C: alpm::db::Db::groups (db.rs:153) ==107909== by 0x1152D8: segfault::main (main.rs:6) ==107909== by 0x11482A: core::ops::function::FnOnce::call_once (function.rs:250) ==107909== by 0x11456D: std::sys_common::backtrace::__rust_begin_short_backtrace (backtrace.rs:134) ==107909== by 0x114A90: std::rt::lang_start::{{closure}} (rt.rs:166) ==107909== by 0x146A9B: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287) ==107909== by 0x146A9B: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:487) ==107909== by 0x146A9B: try + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140) ==107909== by 0x146A9B: {closure#2} (rt.rs:148) ==107909== by 0x146A9B: do_call (panicking.rs:487) ==107909== by 0x146A9B: try (panicking.rs:451) ==107909== by 0x146A9B: catch_unwind (panic.rs:140) ==107909== by 0x146A9B: std::rt::lang_start_internal (rt.rs:148) ==107909== ==107909== ==107909== HEAP SUMMARY: ==107909== in use at exit: 0 bytes in 0 blocks ==107909== total heap usage: 51,041 allocs, 51,064 frees, 7,679,068 bytes allocated ==107909== ==107909== All heap blocks were freed -- no leaks are possible ==107909== ==107909== For lists of detected and suppressed errors, rerun with: -s ==107909== ERROR SUMMARY: 161 errors from 7 contexts (suppressed: 0 from 0) ```

I can also reproduce this in the latest version of paru (commit 257e01155501e3f93ed218f3853156a030b20c58) so I don't think it's from how I'm setting up the Alpm struct. paru patch file:

diff --git a/src/config.rs b/src/config.rs
index 946d2d2..a9938d0 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -853,6 +853,8 @@ impl Config {
                 )
             })?;

+        alpm.localdb().groups().unwrap();
+
         alpm.set_question_cb((self.no_confirm, self.color), question);
         alpm.set_dl_cb((), download);
         alpm.set_log_cb(self.color, log);
Morganamilo commented 1 year ago

Thanks. Don't know how no one noticed before. Fixed and return type has been changed. Pushing as a bug release as no one could actually use this function before anyway so the breaking change is irrelevant.

Morganamilo commented 1 year ago

Also just noticed new2() is a function that exists apparently. I think this may have been a test function that accidentally hit release whoops.