delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/12/22/15:47:00

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Sat, 22 Dec 2007 15:46:23 -0500 (EST)
From: Igor Peshansky <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Mike Boone <boonedocks AT gmail DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: Ruby on Rails 2.0.2/Cygwin Bug
In-Reply-To: <d45df6780712211913k512c08d4s8d026ecef70dc1cb@mail.gmail.com>
Message-ID: <Pine.GSO.4.63.0712221541210.4432@access1.cims.nyu.edu>
References: <d45df6780712191829xaab8c3kc844f16d04d247ad AT mail DOT gmail DOT com> <d45df6780712211913k512c08d4s8d026ecef70dc1cb AT mail DOT gmail DOT com>
MIME-Version: 1.0
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Fri, 21 Dec 2007, Mike Boone wrote:

> I came up with a simple Ruby snippet that reproduces the problem. I'd
> appreciate it if other Cygwin users would try it. You can change the
> "cause_failure = true" line to say false and it will run.
>
> --urandom_test.rb------
> # Test failure of reading /dev/urandom after failed require
>
> # this method is from the Rails' source secret_key_generator.rb
> def generate_secret_with_urandom
>   return File.read("/dev/urandom", 64).unpack("H*")[0]
> end
>
> cause_failure = true
>
> begin
>   require 'nonexistent_file'
> rescue LoadError
>   puts '' unless cause_failure
> end
>
> puts generate_secret_with_urandom
> -----------------------
>
> So far, the strace output of this is too low level for me to follow.
> Perhaps it will be clear to a regular Cygwin hacker.
>
> BTW, I'm running "ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-cygwin]".

As I mentioned before, I don't use Ruby too often.  But I just realized
something: to reproduce the error, you needed a "require
'nonexistent_file'", which will obviously set errno to ENOENT (which is
exactly the error you're seeing).  It's possible that File.read checks
errno and exits right away if it's non-zero, and that nothing resets errno
before File.read.  Inserting the puts call will likely reset errno, thus
avoiding the bug.  So, the bug is probably in Ruby code for exception
handling ("rescue") -- it should reset errno so that subsequent code isn't
affected (and it's also suspicious that the File.read code checks errno
without a valid reason, e.g., a non-zero return value).
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_	    pechtcha AT cs DOT nyu DOT edu | igor AT watson DOT ibm DOT com
ZZZzz /,`.-'`'    -.  ;-;;,_		Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-'		old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"That which is hateful to you, do not do to your neighbor.  That is the whole
Torah; the rest is commentary.  Go and study it." -- Rabbi Hillel

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019