From: Eric Wong Date: 2013-10-23T20:06:22+00:00 Subject: [ruby-core:58003] Re: [ruby-trunk - Bug #9040] Readline duplicate file descriptors but doesn't close them "akr (Akira Tanaka)" wrote: > Issue #9040 has been updated by akr (Akira Tanaka). > > File readline-release-gvl-5.patch added > > normalperson (Eric Wong) wrote: > > > > Btw, on a separate note, it would be a good idea to check the return > > value of fileno() in case another extension accidentally fclose() > > I think avoiding accidental fclose() is not the responsibility of readline_getc(). > It is because readline_getc() cannot determine the FILE structure is closed or not. > So the only appropriate action for the situation is rb_bug() > because fileno() for a closed stream is undefined behavior > (possibly SEGV if memory for FILE structure is returned to OS). Agreed, thanks. On a related note: should rb_fd_set/rb_fd_resize call rb_bug on negative FD? Otherwise it could OOM/SEGV, I think