Giter Site home page Giter Site logo

Kaboom about seeing_is_believing HOT 5 CLOSED

joshcheek avatar joshcheek commented on July 20, 2024
Kaboom

from seeing_is_believing.

Comments (5)

JoshCheek avatar JoshCheek commented on July 20, 2024

Preliminary guess: RSpec and SeeingIsBelieving are fighting over at_exit hooks. I'll look into it more over the weekend.

from seeing_is_believing.

JoshCheek avatar JoshCheek commented on July 20, 2024

Also, it looks like your version is old (I should totally include the version info in that output >.<) because SIB serializes with YAML since version 0.0.23, but yours looks like Marshal

from seeing_is_believing.

JoshCheek avatar JoshCheek commented on July 20, 2024

NVM, I just reproduced it >.<

from seeing_is_believing.

JoshCheek avatar JoshCheek commented on July 20, 2024

Okay, it doesn't blow up in the version that's about to be released, which you can get early if you want, it's on the switching_to_parser branch. I'll add a regression test for it, too.

from seeing_is_believing.

JoshCheek avatar JoshCheek commented on July 20, 2024

Well, this is what I get for going through this at 2AM while sauced, I had version 0.0.22 installed on the version of Ruby I was looking at. It is actually fixed in the currently released 1.0.0. It had to do with invoking a method that was not defined. Ruby raises a NameError, but it's message is not actually an instance of String, it's an instance of NameError::message which is not a valid class name, and can't be allocated (instead of calling .new on it, you call .! (I shit you not)) and thus was unable to deserialize it. I've had a workaround for that for a while now (basically serializing backtraces and messages independently of the exceptions).

Here is an example of what was happening.

require 'yaml'

# get a NameError with a message that isn't a String
exception = nil
begin
  abc
rescue
  exception = $! # => #<NameError: undefined local variable or method `abc' for main:Object>
end


# get the message class (b/c its name is invalid, can't just do `NameError::message` or even `NameError.const_get :message`)
message_class = nil
ObjectSpace.each_object(Class) { |c| message_class = c if c.name == 'NameError::message' }
message_class # => NameError::message


# show that you can't instantiate it with .new, (because it delegates to .allocate, which is undefined... good troll, Ruby, good troll)
begin
  message_class.new
rescue
  $! # => #<TypeError: allocator undefined for NameError::message>
end


# so how do we instantiate this thing? with `.!`, of course, lol
new_message = message_class.! 'o', 'm', 'g' # => #<NameError::message:0x007f836b07eae0>
new_message.to_str                          # => "o"


# show that the instance of this class is our message
message = nil
ObjectSpace.each_object(message_class) { |m| message = m }
message
message.to_str
exception.message # => "undefined local variable or method `abc' for main:Object"


# an example showing we can't serialize the exception because of this message class
YAML.load YAML.dump exception  # ~> TypeError: allocator undefined for NameError::message

# ~> TypeError
# ~> allocator undefined for NameError::message
# ~>
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:303:in `allocate'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:303:in `revive'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:178:in `visit_Psych_Nodes_Mapping'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/visitor.rb:15:in `visit'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/visitor.rb:5:in `accept'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:20:in `accept'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:210:in `block in visit_Psych_Nodes_Mapping'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:210:in `map'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:210:in `visit_Psych_Nodes_Mapping'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/visitor.rb:15:in `visit'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/visitor.rb:5:in `accept'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:20:in `accept'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:240:in `visit_Psych_Nodes_Document'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/visitor.rb:15:in `visit'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/visitor.rb:5:in `accept'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:20:in `accept'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/nodes/node.rb:35:in `to_ruby'
# ~> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych.rb:130:in `load'
# ~> /var/folders/80/_k3gdsls7vs760m_8v6h651w0000gn/T/seeing_is_believing_temp_dir20130809-69619-1h6c2i0/program.rb:40:in `<main>'

from seeing_is_believing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.