Skip to content

Instantly share code, notes, and snippets.

@ashchan
Created January 23, 2011 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ashchan/791984 to your computer and use it in GitHub Desktop.
Save ashchan/791984 to your computer and use it in GitHub Desktop.
https calling in NSOperation caused Segmentation fault
framework 'Cocoa'
require 'net/https'
class SomeOperation < NSOperation
def main
http = Net::HTTP.new("mail.google.com", 443)
http.use_ssl = true
response = nil
http.start do |h|
req = Net::HTTP::Get.new("/mail/feed/atom")
req.basic_auth('ashchan', 'pass')
response = h.request(req)
end
puts response.code
end
end
class AppDelegate
def applicationDidFinishLaunching(notification)
queue = NSOperationQueue.alloc.init
2.times do
queue.addOperation SomeOperation.new
end
end
end
app = NSApplication.sharedApplication
app.delegate = AppDelegate.new
app.run
# MacRuby 0.9
# macruby -w https_nsoperation.rb
# result:
# unknown: warning: Float 1.797693134862316E+3... out of range
# unknown: warning: Float 1.797693134862316E+3... out of range
# unknown: warning: instance variable @hostname not initialized
# unknown: warning: instance variable @hostname not initialized
# Segmentation fault
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment