Ezra Zygmuntowicz
4/18/2007 3:05:00 AM
Hi Bill-
On Apr 17, 2007, at 4:34 PM, Bill Kelly wrote:
> Hi,
>
> I'm getting a deadlock on this small program, on both Windows
> and Linux:
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> require 'net/ftp'
> Thread.abort_on_exception = true
> ftp = Net::FTP.new('ftp.idsoftware.com')
> p( Thread.new {$SAFE=4; ftp.login('anonymous', 'abc@def.com')}.value )
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> # ruby -v ftp_safe_test.rb
> ruby 1.8.4 (2005-12-24) [i386-mswin32]
> ftp_safe_test.rb:4:in `value': Thread(0x27855c8): deadlock (fatal)
> from ftp_safe_test.rb:4
>
>
> $ ruby -v safe_ftp_test.rb
> ruby 1.8.4 (2005-12-24) [i686-linux]
> safe_ftp_test.rb:4:in `value': Thread(0x4f060748): deadlock (fatal)
> from safe_ftp_test.rb:4
>
>
> Now, I didn't necessarily expect the code to WORK at $SAFE=4,
> but I was anticipating a SecurityError rather than a deadlock.
>
> (I've tried it with Thread.abort_on_exception both true and
> false, same result.)
>
> Any thoughts?
>
> Thanks,
>
> Regards,
>
> Bill
Are you using ruby 1.8.6 by chance? If so install the laets
fastthread gem and require it in your script to see if it fixes the
deadlock. Unfortunately the fastthread code in the ruby1.8.6 release
has some bugs that are fixed in the fastthread gem
Cheers-
-- Ezra Zygmuntowicz
-- Lead Rails Evangelist
-- ez@engineyard.com
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)