[MacRuby] #633: Segmentation fault using Net::SMTP on background thread
#633: Segmentation fault using Net::SMTP on background thread -----------------------------------+---------------------------------------- Reporter: wbyoung@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: -----------------------------------+---------------------------------------- The following code causes a segmentation fault. The third line from the bottom is commented out, but executes the test method on the main thread and works fine. I'm using MacRuby version 0.5. {{{ require 'net/smtp' framework 'Cocoa' class Test def execute username = '' password = '' server = '' to = '' port = 0 connection = Net::SMTP.new(server, port) connection.enable_starttls_auto() connection.start(server, username, password, :login) { |smtp| smtp.send_message "Subject: Example\r\n\r\nHello world!\r\n", nil, [to] } end end # Test.new.execute NSThread.detachNewThreadSelector("execute", toTarget:Test.new, withObject:nil) NSThread.sleepForTimeInterval(60) }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/633> MacRuby <http://macruby.org/>
#633: Segmentation fault using Net::SMTP on background thread -----------------------------------+---------------------------------------- Reporter: wbyoung@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: major | Milestone: Component: MacRuby | Resolution: invalid Keywords: | -----------------------------------+---------------------------------------- Changes (by lsansonetti@…): * status: new => closed * resolution: => invalid Comment: Sorry for the late reply. It crashes when unwinding the stack, because the #execute method raises an exception, but since it's called from pure Cocoa code (NSThread), it cannot catch it. There is little we can do here. I recommend to wrap the code you execute concurrently into an exception handler (which you should always do, since exceptions in threads will not be notified otherwise) and/or use Thread class and not NSThread. -- Ticket URL: <http://www.macruby.org/trac/ticket/633#comment:1> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby