pijul_org / pijul

#409 Panic when deleting conflicted files, then `pj patch`

Opened by jimbo1qaz, on June 23, 2019
Open
jimbo1qaz commented on June 23, 2019

I applied a conflicting patch on top of an existing branch. Pijul insisted that I had some renamed(?) binary files, and would never stop regardless if I ran pijul revert and said a. So I recorded it (pj patch consists of many lines of - (Invalid UTF-8)).\r+ \r + I deleted some conflicted files in a file manager, and then recorded a patch. The files I deleted were deleted in 1 patch but not the other, and consisted exclusively of:\r + \r +

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r                                                                                                                                                                                                                                      +
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\r                                                                                                                                                                                                                                      +
```\r                                                                                                                                                                                                                                                                   +
\r                                                                                                                                                                                                                                                                      +
When attempting to view the patch, I get a panic.\r                                                                                                                                                                                                                     +
\r                                                                                                                                                                                                                                                                      +
If you want a minimal reproducing repo, I can find one later.\r                                                                                                                                                                                                         +
\r                                                                                                                                                                                                                                                                      +
```\r                                                                                                                                                                                                                                                                   +
~/src/pijul-ft ❯❯❯ pj record\r                                                                                                                                                                                                                                          +
deleted file: config.h\r                                                                                                                                                                                                                                                +
\r                                                                                                                                                                                                                                                                      +
Shall I record this change? (1/8) [ynkad?] a\r                                                                                                                                                                                                                          +
\r                                                                                                                                                                                                                                                                      +
What is the name of this patch? Remove empty files\r                                                                                                                                                                                                                    +
Recorded patch 7VcXPWW7UK3ewjj6Mm44dCKqNNTzE7wDzSShrMd9BGowAH6PY3E3b9sypc9yADZ6JfJ41YQv6txqMx6VaoR8iuXU\r                                                                                                                                                               +
~/src/pijul-ft ❯❯❯ pj patch 7VcXPWW7UK3ewjj6Mm44dCKqNNTzE7wDzSShrMd9BGowAH6PY3E3b9sypc9yADZ6JfJ41YQv6txqMx6VaoR8iuXU\r                                                                                                                                                  +
- (Invalid UTF-8)\r                                                                                                                                                                                                                                                     +
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/slice/mod.rs:2455:10\r                                                                                                    +
stack backtrace:\r                                                                                                                                                                                                                                                      +
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace\r                                                                                                                                                                                                       +
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39\r                                                                                                                                                                                                     +
   1: std::sys_common::backtrace::_print\r                                                                                                                                                                                                                              +
             at src/libstd/sys_common/backtrace.rs:70\r                                                                                                                                                                                                                 +
   2: std::panicking::default_hook::{{closure}}\r                                                                                                                                                                                                                       +
             at src/libstd/sys_common/backtrace.rs:58\r                                                                                                                                                                                                                 +
             at src/libstd/panicking.rs:200\r                                                                                                                                                                                                                           +
   3: std::panicking::default_hook\r                                                                                                                                                                                                                                    +
             at src/libstd/panicking.rs:215\r                                                                                                                                                                                                                           +
   4: std::panicking::rust_panic_with_hook\r                                                                                                                                                                                                                            +
             at src/libstd/panicking.rs:478\r                                                                                                                                                                                                                           +
   5: std::panicking::continue_panic_fmt\r                                                                                                                                                                                                                              +
             at src/libstd/panicking.rs:385\r                                                                                                                                                                                                                           +
   6: rust_begin_unwind\r                                                                                                                                                                                                                                               +
             at src/libstd/panicking.rs:312\r                                                                                                                                                                                                                           +
   7: core::panicking::panic_fmt\r                                                                                                                                                                                                                                      +
             at src/libcore/panicking.rs:85\r                                                                                                                                                                                                                           +
   8: core::panicking::panic_bounds_check\r                                                                                                                                                                                                                             +
             at src/libcore/panicking.rs:61\r                                                                                                                                                                                                                           +
   9: pijul::commands::patch::run\r                                                                                                                                                                                                                                     +
  10: pijul::main\r                                                                                                                                                                                                                                                     +
  11: std::rt::lang_start::{{closure}}\r                                                                                                                                                                                                                                +
  12: std::panicking::try::do_call\r                                                                                                                                                                                                                                    +
             at src/libstd/rt.rs:49\r                                                                                                                                                                                                                                   +
             at src/libstd/panicking.rs:297\r                                                                                                                                                                                                                           +
  13: __rust_maybe_catch_panic\r                                                                                                                                                                                                                                        +
             at src/libpanic_unwind/lib.rs:92\r                                                                                                                                                                                                                         +
  14: std::rt::lang_start_internal\r                                                                                                                                                                                                                                    +
             at src/libstd/panicking.rs:276\r                                                                                                                                                                                                                           +
             at src/libstd/panic.rs:388\r                                                                                                                                                                                                                               +
             at src/libstd/rt.rs:48\r                                                                                                                                                                                                                                   +
  15: main\r                                                                                                                                                                                                                                                            +
  16: __libc_start_main\r                                                                                                                                                                                                                                               +
  17: _start\r                                                                                                                                                                                                                                                          +
jimbo1qaz commented on June 27, 2019

I reproduced a bug at https://www.dropbox.com/s/gm1al62jsty608o/pijul-ft.pijul.7z?dl=1 .\r + \r + I built pijul master debug, and found that pijul patch 8rwkH7x5nQ1F6DYkJabm6ZjVzwF4fKfHf6NKnjmH4PHBwtBgoEUyU7ouqELR5wB14E7QN38qNSD1hSSxBJQ5xEnW (in the j0cc-from-vanilla branch) would crash immediately without printing any valid file diffs first.\r+ \r + I ran gdb -args pijul patch 8rwkH7x5nQ1F6DYkJabm6ZjVzwF4fKfHf6NKnjmH4PHBwtBgoEUyU7ouqELR5wB14E7QN38qNSD1hSSxBJQ5xEnW and got the following traceback:\r + \r +

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libcore/slice/mod.rs:2686:10\r                                                                                        +
stack backtrace:\r                                                                                                                                                                                                                                          +
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace\r                                                                                                                                                                                           +
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39\r                                                                                                                                                                                         +
   1: std::sys_common::backtrace::_print\r                                                                                                                                                                                                                  +
             at src/libstd/sys_common/backtrace.rs:71\r                                                                                                                                                                                                     +
   2: std::panicking::default_hook::{{closure}}\r                                                                                                                                                                                                           +
             at src/libstd/sys_common/backtrace.rs:59\r                                                                                                                                                                                                     +
             at src/libstd/panicking.rs:197\r                                                                                                                                                                                                               +
   3: std::panicking::default_hook\r                                                                                                                                                                                                                        +
             at src/libstd/panicking.rs:211\r                                                                                                                                                                                                               +
   4: std::panicking::rust_panic_with_hook\r                                                                                                                                                                                                                +
             at src/libstd/panicking.rs:474\r                                                                                                                                                                                                               +
   5: std::panicking::continue_panic_fmt\r                                                                                                                                                                                                                  +
             at src/libstd/panicking.rs:381\r                                                                                                                                                                                                               +
   6: rust_begin_unwind\r                                                                                                                                                                                                                                   +
             at src/libstd/panicking.rs:308\r                                                                                                                                                                                                               +
   7: core::panicking::panic_fmt\r                                                                                                                                                                                                                          +
             at src/libcore/panicking.rs:85\r                                                                                                                                                                                                               +
   8: core::panicking::panic_bounds_check\r                                                                                                                                                                                                                 +
             at src/libcore/panicking.rs:61\r                                                                                                                                                                                                               +
   9: <usize as core::slice::SliceIndex<[T]>>::index\r                                                                                                                                                                                                      +
             at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libcore/slice/mod.rs:2686\r                                                                                                                                                             +
  10: core::slice::&lt;impl core::ops::index::Index<i> for [T]&gt;::index\r                                                                                                                                                                                       +
             at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libcore/slice/mod.rs:2543\r                                                                                                                                                             +
  11: &lt;alloc::vec::Vec&lt;T&gt; as core::ops::index::Index<i>&gt;::index\r                                                                                                                                                                                           +
             at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/liballoc/vec.rs:1677\r                                                                                                                                                                  +
  12: pijul::commands::patch::render_new_edges\r                                                                                                                                                                                                            +
             at pijul/src/commands/patch.rs:370\r                                                                                                                                                                                                           +
  13: pijul::commands::patch::print_patch\r                                                                                                                                                                                                                 +
             at pijul/src/commands/patch.rs:172\r                                                                                                                                                                                                           +
  14: pijul::commands::patch::run\r                                                                                                                                                                                                                         +
             at pijul/src/commands/patch.rs:120\r                                                                                                                                                                                                           +
  15: pijul::main\r                                                                                                                                                                                                                                         +
             at pijul/src/main.rs:72\r                                                                                                                                                                                                                      +
  16: std::rt::lang_start::{{closure}}\r                                                                                                                                                                                                                    +
             at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libstd/rt.rs:64\r                                                                                                                                                                       +
  17: std::panicking::try::do_call\r                                                                                                                                                                                                                        +
             at src/libstd/rt.rs:49\r                                                                                                                                                                                                                       +
             at src/libstd/panicking.rs:293\r                                                                                                                                                                                                               +
  18: __rust_maybe_catch_panic\r                                                                                                                                                                                                                            +
             at src/libpanic_unwind/lib.rs:87\r                                                                                                                                                                                                             +
  19: std::rt::lang_start_internal\r                                                                                                                                                                                                                        +
             at src/libstd/panicking.rs:272\r                                                                                                                                                                                                               +
             at src/libstd/panic.rs:388\r                                                                                                                                                                                                                   +
             at src/libstd/rt.rs:48\r                                                                                                                                                                                                                       +
  20: std::rt::lang_start\r                                                                                                                                                                                                                                 +
             at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libstd/rt.rs:64\r                                                                                                                                                                       +
  21: main\r                                                                                                                                                                                                                                                +
  22: __libc_start_main\r                                                                                                                                                                                                                                   +
  23: _start\r                                                                                                                                                                                                                                              +
\r                                                                                                                                                                                                                                                          +
Breakpoint 1, rust_panic () at src/libstd/panicking.rs:523\r                                                                                                                                                                                                +
523     src/libstd/panicking.rs: No such file or directory.\r                                                                                                                                                                                               +
(gdb) bt\r                                                                                                                                                                                                                                                  +
#0  rust_panic () at src/libstd/panicking.rs:523\r                                                                                                                                                                                                          +
#1  0x000055555716bc0c in rust_panic_with_hook () at src/libstd/panicking.rs:494\r                                                                                                                                                                          +
#2  0x000055555716b652 in continue_panic_fmt () at src/libstd/panicking.rs:381\r                                                                                                                                                                            +
#3  0x000055555716b536 in rust_begin_unwind () at src/libstd/panicking.rs:308\r                                                                                                                                                                             +
#4  0x000055555718972d in panic_fmt () at src/libcore/panicking.rs:85\r                                                                                                                                                                                     +
#5  0x00005555571896e5 in panic_bounds_check () at src/libcore/panicking.rs:61\r                                                                                                                                                                            +
#6  0x0000555555c8946e in &lt;usize as core::slice::SliceIndex&lt;[T]&gt;&gt;::index (self=0, slice=...)\r                                                                                                                                                              +
    at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libcore/slice/mod.rs:2686\r                                                                                                                                                                      +
#7  0x000055555607f617 in core::slice::&lt;impl core::ops::index::Index<i> for [T]&gt;::index (self=..., index=0)\r                                                                                                                                               +
    at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libcore/slice/mod.rs:2543\r                                                                                                                                                                      +
#8  0x0000555555da3887 in &lt;alloc::vec::Vec&lt;T&gt; as core::ops::index::Index<i>&gt;::index (self=0x7fffffff73c8, index=0)\r                                                                                                                                        +
    at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/liballoc/vec.rs:1677\r                                                                                                                                                                           +
#9  0x0000555555bf3f6b in pijul::commands::patch::render_new_edges (term=0x7fffffff7d68, txn=0x7fffffff99f8, branch=0x7fffffff9d30, \r                                                                                                                      +
    buf=0x7fffffff7cf8, internal=..., edges=..., flag=...) at pijul/src/commands/patch.rs:370\r                                                                                                                                                             +
#10 0x0000555555bf1326 in pijul::commands::patch::print_patch (hash=0x7fffffff8d20, patch=0x7fffffff8d70, txn=0x7fffffff99f8, \r                                                                                                                            +
    branch=0x7fffffff9d30) at pijul/src/commands/patch.rs:172\r                                                                                                                                                                                             +
#11 0x0000555555bf03e5 in pijul::commands::patch::run (args=0x555557996eb8) at pijul/src/commands/patch.rs:120\r                                                                                                                                            +
#12 0x000055555613eac1 in pijul::main () at pijul/src/main.rs:72\r                                                                                                                                                                                          +
(gdb) f 0x0000555555bf3f6b\r                                                                                                                                                                                                                                +
#0  0x0000000000000000 in ?? ()\r                                                                                                                                                                                                                           +
(gdb) f 9\r                                                                                                                                                                                                                                                 +
#9  0x0000555555bf3f6b in pijul::commands::patch::render_new_edges (term=0x7fffffff7d68, txn=0x7fffffff99f8, branch=0x7fffffff9d30, \r                                                                                                                      +
    buf=0x7fffffff7cf8, internal=..., edges=..., flag=...) at pijul/src/commands/patch.rs:370\r                                                                                                                                                             +
370                     let mut ret = txn.retrieve(branch, files[0]);\r                                                                                                                                                                                     +