You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change tests/data/flamegraph/bad-lines/bad-lines.txt to the following (adding a blank line):
cksum;_start;__libc_start_main;main;cksum 31
cksum;cksum 6
THIS IS A BAD LINE
cksum;cksum;__GI___fread_unlocked;_IO_file_xsgetn;_IO_file_read;entry_SYSCALL_64_fastpath_[k];sys_read_[k];vfs_read_[k];__vfs_read_[k];ext4_file_read_iter_[k] 1
cksum;main;cksum 19
THIS IS A BAD FRACTIONAL LINE 12V.43
noploop;[unknown] 2
noploop;main 274
noploop;[unknown] 2
Run cargo test flamegraph_should_warn_about_bad_input_lines_with_reversed_stack_ordering
Failure:
---- flamegraph_should_warn_about_bad_input_lines_with_reversed_stack_ordering stdout ----
thread 'flamegraph_should_warn_about_bad_input_lines_with_reversed_stack_ordering' panicked at 'attempt to subtract with overflow', /home/mike/inferno/src/flamegraph/mod.rs:415:60
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
flamegraph_should_warn_about_bad_input_lines_with_reversed_stack_ordering
samples_idx is 0 when we have an empty line, and we are trying to subtract from it.
A simple fix would be to add a check for line.is_empty() at the top of that loop. Alternatively, it seems like the reason we are subtracting 1 from sample_idx is to remove a trailing space from the line, so replacing with &line[..samples_idx].trim_end() would fix it.
The text was updated successfully, but these errors were encountered:
Found while I was investigating #237
Repro:
tests/data/flamegraph/bad-lines/bad-lines.txt
to the following (adding a blank line):cargo test flamegraph_should_warn_about_bad_input_lines_with_reversed_stack_ordering
Failure:
The issue is here: https://github.com/jonhoo/inferno/blob/master/src/flamegraph/mod.rs#L411
samples_idx
is 0 when we have an empty line, and we are trying to subtract from it.A simple fix would be to add a check for
line.is_empty()
at the top of that loop. Alternatively, it seems like the reason we are subtracting 1 from sample_idx is to remove a trailing space from the line, so replacing with&line[..samples_idx].trim_end()
would fix it.The text was updated successfully, but these errors were encountered: