$ enscript --toc --output=foo.ps foo.txt *** glibc detected *** enscript: double free or corruption (!prev): 0x080d2a68 *** ======= Backtrace: ========= /lib/libc.so.6[0x41843c51] /lib/libc.so.6(__libc_free+0x89)[0x418446a9] /lib/libc.so.6(fclose+0x139)[0x418350d9] enscript[0x804c07f] /lib/libc.so.6(__libc_start_main+0xec)[0x417f755c] enscript[0x8049231] ======= Memory map: ======== 08048000-08066000 r-xp 00000000 03:02 429808 /usr/bin/enscript 08066000-0806f000 rw-p 0001d000 03:02 429808 /usr/bin/enscript 0806f000-08122000 rw-p 0806f000 00:00 0 [heap] 41000000-41019000 r-xp 00000000 03:02 8494 /lib/ld-2.3.90.so 41019000-4101a000 r--p 00018000 03:02 8494 /lib/ld-2.3.90.so 4101a000-4101b000 rw-p 00019000 03:02 8494 /lib/ld-2.3.90.so 417e2000-418f4000 r-xp 00000000 03:02 8505 /lib/libc-2.3.90.so 418f4000-418f6000 r--p 00112000 03:02 8505 /lib/libc-2.3.90.so 418f6000-418f8000 rw-p 00114000 03:02 8505 /lib/libc-2.3.90.so 418f8000-418fa000 rw-p 418f8000 00:00 0 418fc000-4191e000 r-xp 00000000 03:02 8521 /lib/libm-2.3.90.so 4191e000-4191f000 r--p 00021000 03:02 8521 /lib/libm-2.3.90.so 4191f000-41920000 rw-p 00022000 03:02 8521 /lib/libm-2.3.90.so 42203000-4220b000 r-xp 00000000 03:02 37729 /usr/lib/gcc/i686-pc-linux-gnu/3.4.4/libgcc_s.so.1 4220b000-4220c000 rw-p 00007000 03:02 37729 /usr/lib/gcc/i686-pc-linux-gnu/3.4.4/libgcc_s.so.1 42691000-426a2000 r-xp 00000000 03:02 8526 /lib/libnsl-2.3.90.so 426a2000-426a3000 r--p 00010000 03:02 8526 /lib/libnsl-2.3.90.so 426a3000-426a4000 rw-p 00011000 03:02 8526 /lib/libnsl-2.3.90.so 426a4000-426a6000 rw-p 426a4000 00:00 0 b7e00000-b7e21000 rw-p b7e00000 00:00 0 b7e21000-b7f00000 ---p b7e21000 00:00 0 b7f49000-b7f69000 rw-p b7f49000 00:00 0 b7f69000-b7f6f000 r-xp 00000000 03:02 8527 /lib/libnss_compat-2.3.90.so b7f6f000-b7f70000 r--p 00006000 03:02 8527 /lib/libnss_compat-2.3.90.so b7f70000-b7f71000 rw-p 00007000 03:02 8527 /lib/libnss_compat-2.3.90.so b7f87000-b7f8f000 r--p 00000000 03:02 429795 /usr/share/locale/en_GB/LC_MESSAGES/enscript.mo b7f8f000-b7f95000 r--s 00000000 03:02 38011 /usr/lib/gconv/gconv-modules.cache b7f95000-b7f96000 r--p 00000000 03:02 45483 /usr/lib/locale/en_GB/LC_MESSAGES/SYS_LC_MESSAGES b7f96000-b7f98000 rw-p b7f96000 00:00 0 b7f9c000-b7f9d000 r-xp 00000000 03:02 37960 /usr/lib/gconv/ISO8859-1.so b7f9d000-b7f9e000 r--p 00001000 03:02 37960 /usr/lib/gconv/ISO8859-1.so b7f9e000-b7f9f000 rw-p 00002000 03:02 37960 /usr/lib/gconv/ISO8859-1.so b7f9f000-b7fa1000 rw-p b7f9f000 00:00 0 b7fa2000-b7faa000 r-xp 00000000 03:02 8529 /lib/libnss_files-2.3.90.so b7faa000-b7fab000 r--p 00007000 03:02 8529 /lib/libnss_files-2.3.90.so b7fab000-b7fac000 rw-p 00008000 03:02 8529 /lib/libnss_files-2.3.90.so b7fac000-b7fb4000 r-xp 00000000 03:02 8531 /lib/libnss_nis-2.3.90.so b7fb4000-b7fb5000 r--p 00007000 03:02 8531 /lib/libnss_nis-2.3.90.so b7fb5000-b7fb6000 rw-p 00008000 03:02 8531 /lib/libnss_nis-2.3.90.so bfda0000-bfdb6000 rw-p bfda0000 00:00 0 [stack] ffffe000-fffff000 ---p 00000000 00:00 0 [vdso] I have analysed the issue and will attach a patch.
Created attachment 72094 [details, diff] 111457.bugs.gentoo.org.patch The bug is: if (is_open (&is, toc_fp, NULL, NULL)) { process_file (_("Table of Contents"), &is, 1); is_close (&is); } /* Clean up toc file. */ fclose (toc_fp); at main.c line 1715, is_close() closes the toc file stream and also closes the toc file, so the fclose (toc_fp) is not needed. This patch also corrects a minor bug: enscript segfaults if given -toc and an invalid input file e.g. $ enscript -toc /spork/is/not/valid -o out.ps enscript: couldn't open input file "/spork/is/not/valid": No such file or directory Segmentation fault This is due to the toc routine not checking that an output stream is open.
Can you please push this patch upstream to the enscript developers? I added it to the gentoo ebuild
OK, I've emailed mtr@iki.fi -- there's no bugzilla for enscript. Thanks for using the patch.