Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault #46

Closed
PSeitz opened this issue Feb 15, 2023 · 2 comments
Closed

Segmentation fault #46

PSeitz opened this issue Feb 15, 2023 · 2 comments

Comments

@PSeitz
Copy link

PSeitz commented Feb 15, 2023

I get a segmentation fault when running the command.

➜  agg_perf git:(agg_perf) ✗ cargo benchcmp control variable
fish: Job 1, 'cargo benchcmp control variable' terminated by signal SIGSEGV (Address boundary error)

➜  agg_perf git:(agg_perf) ✗ bash
[pascal@pascal-rogstrixg513qyg513qy agg_perf]$ cargo benchcmp control variable
Segmentation fault (core dumped)
➜  agg_perf git:(agg_perf) ✗ rustc --version
rustc 1.67.0 (fc594f156 2023-01-24)
➜  agg_perf git:(agg_perf) ✗ uname -a
Linux pascal-rogstrixg513qyg513qy 6.0.19-3-MANJARO #1 SMP PREEMPT_DYNAMIC Wed Jan 18 07:57:11 UTC 2023 x86_64 GNU/Linux

➜ coredumpctl gdb 45907
(gdb) bt
#0  0x0000561c3a520410 in prettytable::TableSlice::get_all_column_width ()
#1  0x0000561c3a52084c in prettytable::TableSlice::print_tty ()
#2  0x0000561c3a51216b in cargo_benchcmp::Args::run ()
#3  0x0000561c3a50f64d in cargo_benchcmp::main ()
#4  0x0000561c3a51e7e3 in std::sys_common::backtrace::__rust_begin_short_backtrace ()
#5  0x0000561c3a51e7f9 in _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hbe8c0291b1f55e55E.llvm.2442119530853037590 ()
#6  0x0000561c3a5e37ac in core::ops::function::impls::{impl#2}::call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> () at library/core/src/ops/function.rs:606
#7  std::panicking::try::do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> () at library/std/src/panicking.rs:483
#8  std::panicking::try<i32, &(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> () at library/std/src/panicking.rs:447
#9  std::panic::catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> () at library/std/src/panic.rs:137
#10 std::rt::lang_s
[control.txt](https://github.com/BurntSushi/cargo-benchcmp/files/10742058/control.txt)
tart_internal::{closure#2} () at library/std/src/rt.rs:148
#11 std::panicking::try::do_call<std::rt::lang_start_internal::{closure_env#2}, isize> () at library/std/src/panicking.rs:483
#12 std::panicking::try<isize, std::rt::lang_start_internal::{closure_env#2}> () at library/std/src/panicking.rs:447
#13 std::panic::catch_unwind<std::rt::lang_start_internal::{closure_env#2}, isize> () at library/std/src/panic.rs:137
#14 std::rt::lang_start_internal () at library/std/src/rt.rs:148
#15 0x0000561c3a513b35 in main ()


variable.txt
control.txt

@BurntSushi
Copy link
Owner

I cannot reproduce:

$ cargo benchcmp --version                        
0.4.3
$ cargo benchcmp control.txt variable.txt                                           
 name                                                                     control.txt ns/iter  variable.txt ns/iter  diff ns/iter  diff %  speedup 
 aggregation::bucket::range::bench::bench_range_100_buckets               282,131              282,131                          0   0.00%   x 1.00 
 aggregation::bucket::range::bench::bench_range_10_buckets                151,993              151,993                          0   0.00%   x 1.00 
 aggregation::tests::bench::bench_aggregation_average_f64                 9,503,993            9,503,993                        0   0.00%   x 1.00 
 aggregation::tests::bench::bench_aggregation_average_u64                 9,086,814            9,086,814                        0   0.00%   x 1.00 
 aggregation::tests::bench::bench_aggregation_average_u64_and_f64         14,361,209           14,361,209                       0   0.00%   x 1.00 
 aggregation::tests::bench::bench_aggregation_histogram_only              17,515,118           17,515,118                       0   0.00%   x 1.00 
 aggregation::tests::bench::bench_aggregation_histogram_only_hard_bounds  16,305,944           16,305,944                       0   0.00%   x 1.00 
 aggregation::tests::bench::bench_aggregation_histogram_with_avg          43,132,488           43,132,488                       0   0.00%   x 1.00 
 aggregation::tests::bench::bench_aggregation_range_only                  12,861,617           12,861,617                       0   0.00%   x 1.00 
 aggregation::tests::bench::bench_aggregation_stats_f64                   9,486,482            9,486,482                        0   0.00%   x 1.00 
 aggregation::tests::bench::bench_aggregation_sub_tree                    21,026,544           21,026,544                       0   0.00%   x 1.00 
 aggregation::tests::bench::bench_aggregation_terms_few                   13,607,468           13,607,468                       0   0.00%   x 1.00 
 aggregation::tests::bench::bench_aggregation_terms_many2                 32,676,636           32,676,636                       0   0.00%   x 1.00 
 aggregation::tests::bench::bench_aggregation_terms_many_order_by_term    33,491,488           33,491,488                       0   0.00%   x 1.00 
 aggregation::tests::bench::bench_aggregation_terms_many_with_sub_agg     93,828,256           93,828,256                       0   0.00%   x 1.00

I don't do much active maintenance on this project, but your stack trace seems to be pointing into the prettytable-rs crate. So I looked to see if it had any unsafe...... and it does..... One usage:

impl<'a> AsRef<TableSlice<'a>> for Table {
    fn as_ref(&self) -> &TableSlice<'a> {
        unsafe {
            // All this is a bit hacky. Let's try to find something else
            let s = &mut *((self as *const Table) as *mut Table);
            s.rows.shrink_to_fit();
            transmute(self)
        }
    }
}

That's converting a & borrow to a &mut borrow, which is instant UB. I don't know if this specific thing explains your seg fault, but it could.

Indeed, it looks like this specific issue has been reported and others noted that it was causing seg faults: phsym/prettytable-rs#145

It was then fixed and 0.10.0 was released: phsym/prettytable-rs#146

I updated to prettytable-rs 0.10.0 was thankfully pretty easy and pushed out cargo-benchcmp 0.4.4 to crates.io. Hopefully that fixes this particular issue.

@PSeitz
Copy link
Author

PSeitz commented Feb 15, 2023

Nice that fixed the issue. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants