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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 memory allocation of 7881122326526296064 bytes failed #878

Closed
osa1 opened this issue Jan 3, 2022 · 15 comments
Closed

馃悰 memory allocation of 7881122326526296064 bytes failed #878

osa1 opened this issue Jan 3, 2022 · 15 comments

Comments

@osa1
Copy link

osa1 commented Jan 3, 2022

When I run delta in my Xubuntu 21.10 x86_64 system I get this error:

$ delta --help
memory allocation of 7881122326526296064 bytes failed
zsh: IOT instruction (core dumped)  delta

I tried with both the latest version on crates.io, and master branch (50ece4b).

@osa1
Copy link
Author

osa1 commented Jan 3, 2022

Debug build doesn't seem to have this issue:

$ ./target/debug/delta
The main way to use delta is to configure it as the pager for git: see https://github.com/dandavison/delta#configuration. You can also use delta to diff two files: `delta file_A file_B`.

$ ./target/release/delta
memory allocation of 7881122326526296064 bytes failed
zsh: IOT instruction (core dumped)  ./target/release/delta

osa1 added a commit to osa1/rcbackup that referenced this issue Jan 3, 2022
@osa1
Copy link
Author

osa1 commented Jan 3, 2022

I tried debugging this, but adding debug = true for the release build hides the bug:

diff --git a/Cargo.toml b/Cargo.toml
index cdcf455..17b0a39 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -62,3 +62,6 @@ features = []
 version = "0.12.4"
 default-features = false
 features = []
+
+[profile.release]
+debug = true

After the diff above release binary seems to work fine.

@osa1
Copy link
Author

osa1 commented Jan 3, 2022

Backtrace of the error: (generated without debug = true)

(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737350377600) at pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=140737350377600) at pthread_kill.c:80
#2  __GI___pthread_kill (threadid=140737350377600, signo=signo@entry=6) at pthread_kill.c:91
#3  0x00007ffff7cb1476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007ffff7c977b7 in __GI_abort () at abort.c:79
#5  0x0000555555852ea7 in std::sys::unix::abort_internal () at library/std/src/sys/unix/mod.rs:259
#6  0x00005555555b1eb6 in std::process::abort () at library/std/src/process.rs:1975
#7  0x000055555584c60e in std::alloc::rust_oom () at library/std/src/alloc.rs:330
#8  0x0000555555868ef7 in alloc::alloc::__alloc_error_handler::__rg_oom () at library/alloc/src/alloc.rs:397
#9  0x00005555555b2d07 in alloc::alloc::handle_alloc_error () at library/alloc/src/alloc.rs:366
#10 0x00005555555a09f5 in alloc::raw_vec::RawVec<T,A>::reserve::do_reserve_and_handle ()
#11 0x00005555556582dd in <&mut bincode::de::Deserializer<R,O> as serde::de::Deserializer>::deserialize_string ()
#12 0x000055555565b88d in <&mut bincode::de::Deserializer<R,O> as serde::de::Deserializer>::deserialize_struct ()
#13 0x00005555555c7adc in <serde::de::impls::<impl serde::de::Deserialize for alloc::vec::Vec<T>>::deserialize::VecVisitor<T> as serde::de::Visitor>::visit_seq ()
#14 0x000055555565c9d5 in <&mut bincode::de::Deserializer<R,O> as serde::de::Deserializer>::deserialize_struct ()
#15 0x0000555555630458 in syntect::dumps::from_binary ()
#16 0x0000555555629f65 in delta::utils::bat::assets::HighlightingAssets::new ()
#17 0x0000555555612d99 in delta::main ()
#18 0x00005555555dcaf3 in std::sys_common::backtrace::__rust_begin_short_backtrace ()
#19 0x00005555555b7ff9 in std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h87d70c75379e17c7 ()
#20 0x000055555584b01b 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 /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:259
#21 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:403
#22 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:367
#23 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:133
#24 std::rt::lang_start_internal::{closure#2} () at library/std/src/rt.rs:128
#25 std::panicking::try::do_call<std::rt::lang_start_internal::{closure#2}, isize> () at library/std/src/panicking.rs:403
#26 std::panicking::try<isize, std::rt::lang_start_internal::{closure#2}> () at library/std/src/panicking.rs:367
#27 std::panic::catch_unwind<std::rt::lang_start_internal::{closure#2}, isize> () at library/std/src/panic.rs:133
#28 std::rt::lang_start_internal () at library/std/src/rt.rs:128
#29 0x00005555556137d2 in main ()

@dandavison
Copy link
Owner

Hi @osa1, I think this crash is being caused by something particular to your environment. It looks like it's crashing while loading the syntax highlighting assets from disk. Delta borrows code from bat to do that. I wonder whether you might have something funny going on with your local bat syntax/theme definitions? Could you try

bat cache --clear

and/or moving ~/.cache/bat and ~/.config/bat out of the way temporarily.

@osa1
Copy link
Author

osa1 commented Jan 3, 2022

Hi @dandavison. I don't have bat installed. I also don't have the directories ~/.config/bat and ~/.cache/bat.

@dandavison
Copy link
Owner

Hm, OK. Let's try to get to the bottom of this. Could you try cargo clean? I'm not sure what's causing it -- I can't reproduce it on my (MacOS) system. Do the binaries for the latest release work for you?

@dandavison
Copy link
Owner

Ah-ha, I can reproduce it, when installing from crates.io:

 ~/.cargo/bin/delta
delta(22280,0x1081c0e00) malloc: can't allocate region
:*** mach_vm_map(size=7881122326526296064, flags: 100) failed (error code=3)
delta(22280,0x1081c0e00) malloc: *** set a breakpoint in malloc_error_break to debug
memory allocation of 7881122326526296064 bytes failed

But I haven't reproduced it by building locally yet. Any help debugging / investigating this appreciated.

@lukehsiao
Copy link

Had this start happening to me as well. Happy to help try and verify hypothesis or fixes on my end.

@dandavison
Copy link
Owner

Hi @lukehsiao, how did you install delta? (and on what OS?)

@dandavison
Copy link
Owner

Seems similar to this from 18 months ago bincode-org/bincode#335

@eigenbahr
Copy link

eigenbahr commented Jan 4, 2022

I have the same issue with the latest release (0.11.3) on Ubuntu 20.04. Installed via cargo install git-delta using rustc/cargo 1.57.0. I also tried the previous two patch versions (0.11.2 & 0.11.1) as well as 0.10.3; all had the same problem.

I'm not a rust person, so I don't know if this is relevant: I had previously installed bat (https://github.com/sharkdp/bat) and it also had this same "memory allocation of ___ bytes failed" core dump. I then realized I missed the --locked flag on the cargo install of bat (should have been cargo install --locked bat). After doing this, bat worked.

@lukehsiao
Copy link

lukehsiao commented Jan 4, 2022

I also installed via cargo install git-delta. This is happening on Ubuntu 20.04.3 LTS (x86_64).

Somewhat surprisingly for me, reinstalling git-delta with

cargo install --force --locked git-delta

Appears to have resolved the issue on my machine.

@lukehsiao
Copy link

It does look like bat users are seeing a similar thing: sharkdp/bat#2013

@osa1
Copy link
Author

osa1 commented Jan 4, 2022

Confirmed that adding --locked to the install command (cargo install --force --locked git-delta) fixes the issue.

@dandavison
Copy link
Owner

Thanks everyone! I'll close this now. My understanding is that

  1. People installing via cargo hit a known bug in syntect (Fix feature semver violations in v4.7.0聽trishume/syntect#403 (comment))
  2. The workaround is cargo install --force --locked git-delta

But please keep the discussion going or re-open if you are encountering this problem and that doesn't describe it.

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

4 participants