Package: patch
Version: 2.7.6-1
patch crashes when trying to apply a git-style patch to a nonexistent
file:
$ patch -p1 nonexistent < git.diff
patching file nonexistent
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file nonexistent.rej
patch: **** Can't reopen file nonexistent : No such file or directory
patch: **** Can't reopen file nonexistent : No such file or directory
patch: **** Can't reopen file nonexistent : No such file or directory
[... hundreds of identical warnings ...]
patch: **** Can't reopen file nonexistent : No such file or directory
patch: **** Can't reopen file nonexistent : No such file or directory
patch: **** Can't reopen file nonexistent : No such file or directory
patch: **** Can't reopen file nonexistent : Too many open files
patch: **** Can't create file nonexistent.orig : Too many open files
patch: **** Can't create file nonexistent.orig : Too many open files
patch: **** Can't create file nonexistent.orig : Too many open files
[... hundreds of identical warnings ...]
patch: **** Can't create file nonexistent.orig : Too many open files
patch: **** Can't create file nonexistent.orig : Too many open files
patch: **** Can't create file nonexistent.orig : Too many open files
patch: **** Can't create file nonexistent.origSegmentation fault
GDB suggests it's an infinite recursion that eventually overflew the
stack:
#0 0xf7db06dd in _IO_vfprintf_internal (s=0xf7f38ce0 <_IO_2_1_stderr_>, format=0xf7ee2c1d
"%s%s%s\n", ap=0xff31d3b8 "G\037`V\300\373\355\367e\377\355\367\334\323\061\377") at
vfprintf.c:1244
#1 0xf7dcca1b in locked_vfxprintf (fp=fp@entry=0xf7f38ce0 <_IO_2_1_stderr_>, fmt=<optimized
out>, fmt@entry=0xf7ee2c1d "%s%s%s\n", ap=ap@entry=0xff31d3b8
"G\037`V\300\373\355\367e\377\355\367\334\323\061\377") at fxprintf.c:30
#2 0xf7dccb48 in __fxprintf (fp=0xf7f38ce0 <_IO_2_1_stderr_>, fmt=0xf7ee2c1d
"%s%s%s\n") at fxprintf.c:74
#3 0xf7dca44c in perror_internal (fp=0xf7f38ce0 <_IO_2_1_stderr_>, s=0x56601f47 "
", errnum=<optimized out>) at perror.c:39
#4 0xf7dca4c4 in __GI_perror (s=0x56601f47 " ") at perror.c:67
#5 0x565eb485 in pfatal (format=0x565ffcdb "Can't create file %s") at
util.c:963
#6 0x565eb800 in create_file (file=0x5670c660 "nonexistent.orig",
open_flags=1, mode=33152, to_dir_known_to_exist=true) at util.c:574
#7 0x565eba06 in copy_file (from=0x56693940 "nonexistent", to=0x5670c660
"nonexistent.orig", tost=0x0, to_flags=0, mode=33152, to_dir_known_to_exist=true) at
util.c:633
#8 0x565ebbc0 in create_backup_copy (from=from@entry=0x56693940 "nonexistent",
to=to@entry=0x5670c660 "nonexistent.orig", st=st@entry=0x56694fa4,
to_dir_known_to_exist=true) at util.c:314
#9 0x565ebf98 in create_backup (to=0x56693940 "nonexistent",
to_st=0x56694fa4, leave_original=true) at util.c:407
#10 0x565e17da in output_file_now (from=<optimized out>,
from_needs_removal=0xff31d9b3, from_st=<optimized out>, to=0x0, mode=32768,
backup=true) at patch.c:1869
#11 0x565e18c1 in output_files (st=0x0) at patch.c:1949
#12 0x565e2659 in fatal_exit (sig=0) at patch.c:1978
#13 0x565eb499 in pfatal (format=0x565ffcdb "Can't create file %s") at
util.c:965
#14 0x565eb800 in create_file (file=0x5670c640 "nonexistent.orig",
open_flags=1, mode=33152, to_dir_known_to_exist=true) at util.c:574
#15 0x565eba06 in copy_file (from=0x56693940 "nonexistent", to=0x5670c640
"nonexistent.orig", tost=0x0, to_flags=0, mode=33152, to_dir_known_to_exist=true) at
util.c:633
#16 0x565ebbc0 in create_backup_copy (from=from@entry=0x56693940 "nonexistent",
to=to@entry=0x5670c640 "nonexistent.orig", st=st@entry=0x56694fa4,
to_dir_known_to_exist=true) at util.c:314
#17 0x565ebf98 in create_backup (to=0x56693940 "nonexistent",
to_st=0x56694fa4, leave_original=true) at util.c:407
#18 0x565e17da in output_file_now (from=<optimized out>,
from_needs_removal=0xff31dbd3, from_st=<optimized out>, to=0x0, mode=32768,
backup=true) at patch.c:1869
#19 0x565e18c1 in output_files (st=0x0) at patch.c:1949
#20 0x565e2659 in fatal_exit (sig=0) at patch.c:1978
[...]
#123277 0x565eb499 in pfatal (format=0x56601f9f "Can't reopen file %s") at
util.c:965
#123278 0x565eb8ef in copy_to_fd (from=0x56693940 "nonexistent", tofd=4) at
util.c:591
#123279 0x565eba13 in copy_file (from=0x56693940 "nonexistent", to=0x56693fb0
"nonexistent.orig", tost=0x0, to_flags=0, mode=33152, to_dir_known_to_exist=true) at
util.c:635
#123280 0x565ebbc0 in create_backup_copy (from=from@entry=0x56693940 "nonexistent",
to=to@entry=0x56693fb0 "nonexistent.orig", st=st@entry=0x56694fa4,
to_dir_known_to_exist=true) at util.c:314
#123281 0x565ebf98 in create_backup (to=0x56693940 "nonexistent",
to_st=0x56694fa4, leave_original=true) at util.c:407
#123282 0x565e17da in output_file_now (from=<optimized out>,
from_needs_removal=0xffb1c1d3, from_st=<optimized out>, to=0x0, mode=32768,
backup=true) at patch.c:1869
#123283 0x565e18c1 in output_files (st=0x0) at patch.c:1949
#123284 0x565e2659 in fatal_exit (sig=0) at patch.c:1978
#123285 0x565eb499 in pfatal (format=0x56601f9f "Can't reopen file %s") at
util.c:965
#123286 0x565eb8ef in copy_to_fd (from=0x56693940 "nonexistent", tofd=3) at
util.c:591
#123287 0x565eba13 in copy_file (from=0x56693940 "nonexistent", to=0x56693900
"nonexistent.orig", tost=0x0, to_flags=0, mode=33152, to_dir_known_to_exist=true) at
util.c:635
#123288 0x565ebbc0 in create_backup_copy (from=from@entry=0x56693940 "nonexistent",
to=to@entry=0x56693900 "nonexistent.orig", st=st@entry=0x56694fa4,
to_dir_known_to_exist=true) at util.c:314
#123289 0x565ebf98 in create_backup (to=0x56693940 "nonexistent",
to_st=0x56694fa4, leave_original=true) at util.c:407
#123290 0x565e17da in output_file_now (from=<optimized out>,
from_needs_removal=0xffb1c3f3, from_st=<optimized out>, to=0x0, mode=32768,
backup=true) at patch.c:1869
#123291 0x565e18c1 in output_files (st=0x0) at patch.c:1949
#123292 0x565dfe9c in main (argc=<optimized out>, argv=<optimized out>) at
patch.c:683
-- System Information:
Architecture: i386
Versions of packages patch depends on:
ii libc6 2.26-6
--
Jakub Wilk
diff --git a/x b/x
--- a/x
+++ b/x
@@ -1 +1 @@
-a
+b