2.2beta3 (v9) crashes when reading faulty stuff from STDIN

Here you can discuss and share functionality improvements and helper programs to make Context Free better.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
User avatar
TorfusPolymorphus
Posts: 27
Joined: Sun Dec 28, 2008 2:16 pm
Contact:

2.2beta3 (v9) crashes when reading faulty stuff from STDIN

Post by TorfusPolymorphus »

When piping stuff with syntax errors into cfdg 2.2beta3 (v9) the latter crashes:

Code: Select all

torf ~/projects/cfdg $ echo "whatever" | cfdg - crash.png
Reading rules file -                            
Line 1: Parse error - syntax error                            
*** glibc detected *** cfdg: munmap_chunk(): invalid pointer: 0x080923c0 ***
======= Backtrace: =========
/lib/libc.so.6[0xb7d46a00]
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6(_ZdlPv+0x21)[0xb7f071a1]
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6(_ZNSiD0Ev+0x4b)[0xb7eb68fb]
cfdg[0x806141c]
cfdg[0x804ba53]
cfdg[0x807b706]
/lib/libc.so.6(__libc_start_main+0xdc)[0xb7cf6fdc]
cfdg(_ZNSt15basic_streambufIcSt11char_traitsIcEE6xsputnEPKci+0xa5)[0x804b601]
======= Memory map: ========
08048000-08090000 r-xp 00000000 08:07 1999503    /home/torf/apps/ContextFree2.2beta3/cfdg
08090000-08091000 r--p 00047000 08:07 1999503    /home/torf/apps/ContextFree2.2beta3/cfdg
08091000-08093000 rw-p 00048000 08:07 1999503    /home/torf/apps/ContextFree2.2beta3/cfdg
08093000-080b6000 rw-p 08093000 00:00 0          [heap]
b7cb9000-b7cbb000 rw-p b7cb9000 00:00 0 
b7cbb000-b7cdf000 r-xp 00000000 08:07 4587697    /lib/libm-2.6.1.so
b7cdf000-b7ce0000 r--p 00023000 08:07 4587697    /lib/libm-2.6.1.so
b7ce0000-b7ce1000 rw-p 00024000 08:07 4587697    /lib/libm-2.6.1.so
b7ce1000-b7e0b000 r-xp 00000000 08:07 4587682    /lib/libc-2.6.1.so
b7e0b000-b7e0d000 r--p 0012a000 08:07 4587682    /lib/libc-2.6.1.so
b7e0d000-b7e0e000 rw-p 0012c000 08:07 4587682    /lib/libc-2.6.1.so
b7e0e000-b7e11000 rw-p b7e0e000 00:00 0 
b7e11000-b7e1b000 r-xp 00000000 08:07 10273165   /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libgcc_s.so.1
b7e1b000-b7e1c000 r--p 00009000 08:07 10273165   /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libgcc_s.so.1
b7e1c000-b7e1d000 rw-p 0000a000 08:07 10273165   /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libgcc_s.so.1
b7e1d000-b7e2e000 r-xp 00000000 08:07 6946991    /lib/libz.so.1.2.3
b7e2e000-b7e2f000 rw-p 00010000 08:07 6946991    /lib/libz.so.1.2.3
b7e2f000-b7e51000 r-xp 00000000 08:07 1949760    /usr/lib/libpng12.so.0.26.0
b7e51000-b7e52000 r--p 00021000 08:07 1949760    /usr/lib/libpng12.so.0.26.0
b7e52000-b7e53000 rw-p 00022000 08:07 1949760    /usr/lib/libpng12.so.0.26.0
b7e53000-b7f31000 r-xp 00000000 08:07 10273166   /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6.0.8
b7f31000-b7f35000 r--p 000dd000 08:07 10273166   /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6.0.8
b7f35000-b7f36000 rw-p 000e1000 08:07 10273166   /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6.0.8
b7f36000-b7f3d000 rw-p b7f36000 00:00 0 
b7f54000-b7f56000 rw-p b7f54000 00:00 0 
b7f56000-b7f70000 r-xp 00000000 08:07 4587686    /lib/ld-2.6.1.so
b7f70000-b7f71000 r--p 00019000 08:07 4587686    /lib/ld-2.6.1.so
b7f71000-b7f72000 rw-p 0001a000 08:07 4587686    /lib/ld-2.6.1.so
bf95c000-bf971000 rw-p bffeb000 00:00 0          [stack]
ffffe000-fffff000 r-xp 00000000 00:00 0          [vdso]
Aborted
This is on Linux. Piping valid cfdg files into cfdg works fine, as does giving a input file with syntax errors via a parameter (the latter raising an syntax error, of course, but without crash).

Let me know if you need further information.

User avatar
MtnViewJohn
Site Admin
Posts: 875
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Post by MtnViewJohn »

Nope. That's enough information to reproduce the problem. Piping a cfdg file from stdin causes cfdg to use std::cin as the source. But you can't delete std::cin so I have code to prevent deleting std::cin. Only it fails to be called if there is a syntax error.

Post Reply