# Ungetc

**URL:** <https://www.ruby-forum.com/t/ungetc/112981>\
**Category:** Development\
**Created:** [August 25, 2007, 11:33am UTC](https://www.ruby-forum.com/t/ungetc/112981 "2007-08-25T11:33:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tanaka\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@Tanaka\_A](https://www.ruby-forum.com/u/Tanaka_A)\
**Post date:** [August 25, 2007, 11:33am UTC](https://www.ruby-forum.com/t/ungetc/112981/1 "2007-08-25T11:33:50Z")

</div>

e$B$^$:$O!"0J2\<$N$h$&$K$9$k$He(B core e$B$rEG$-$^$9!#e(B

% ./ruby -ve ‘10000.times { STDIN.ungetc “a” }’  
ruby 1.9.0 (2007-08-25 patchlevel 0) [i686-linux]  
\*\*\* glibc detected \*\*\* free(): invalid next size (normal): 0x081bdc40

* * *

zsh: abort (core dumped) ./ruby -ve ‘10000.times { STDIN.ungetc “a” }’  
% gdb ruby core.24221  
GNU gdb 6.4.90-debian  
Copyright © 2006 Free Software Foundation, Inc.  
GDB is free software, covered by the GNU General Public License, and you  
are  
welcome to change it and/or distribute copies of it under certain  
conditions.  
Type “show copying” to see the conditions.  
There is absolutely no warranty for GDB. Type “show warranty” for  
details.  
This GDB was configured as “i486-linux-gnu”…Using host libthread\_db  
library “/lib/tls/libthread\_db.so.1”.

warning: Can’t read pathname for load map: Input/output error.  
Reading symbols from /lib/tls/libpthread.so.0…done.  
Loaded symbols for /lib/tls/libpthread.so.0  
Reading symbols from /lib/tls/libdl.so.2…done.  
Loaded symbols for /lib/tls/libdl.so.2  
Reading symbols from /lib/tls/libcrypt.so.1…done.  
Loaded symbols for /lib/tls/libcrypt.so.1  
Reading symbols from /lib/tls/libm.so.6…done.  
Loaded symbols for /lib/tls/libm.so.6  
Reading symbols from /lib/tls/libc.so.6…done.  
Loaded symbols for /lib/tls/libc.so.6  
Reading symbols from /lib/ld-linux.so.2…done.  
Loaded symbols for /lib/ld-linux.so.2  
Core was generated by `./ruby -ve 10000.times { STDIN.ungetc “a” }’.  
Program terminated with signal 6, Aborted.  
#0 0xb7e04947 in raise () from /lib/tls/libc.so.6  
(gdb) bt  
#0 0xb7e04947 in raise () from /lib/tls/libc.so.6  
#1 0xb7e060c9 in abort () from /lib/tls/libc.so.6  
#2 0xb7e3a08a in \_\_fsetlocking () from /lib/tls/libc.so.6  
#3 0xb7e4194f in mallopt () from /lib/tls/libc.so.6  
#4 0xb7e419f2 in free () from /lib/tls/libc.so.6  
#5 0x08067042 in rb\_io\_fptr\_finalize (fptr=0x81a9d08) at io.c:2331  
#6 0x0806332b in rb\_gc\_call\_finalizer\_at\_exit () at gc.c:2014  
#7 0x08059d44 in ruby\_finalize\_1 () at eval.c:147  
#8 0x08059e2b in ruby\_cleanup (ex=0) at eval.c:181  
#9 0x0805a09b in ruby\_run\_node (n=0xb7d38314) at eval.c:256  
#10 0x080573f5 in main (argc=1236284, argv=0xb7f61518, envp=0xb7f93080)  
at main.c:46  
(gdb)

io.c e$B$NJQ99$r8+$k$H!“e(Bungetc failed e$B$NNc30H/@8%3!\<%I$,\>C$($Fe(B  
e$B$$$k$N$G$9$,!”%P%C%U%!$O8GDjD9$G$"$k$?$a!"$?$/$5$se(B ungetc e$B$9e(B  
e$B$l$P!"$$$:$l$O$$$C$Q$$$K$J$C$F\<:GT$K$;$6$k$r$($^$;$s!#e(B
