bloom-lang / bud

Prototype Bud runtime (Bloom Under Development)
http://bloom-lang.net
Other
856 stars 59 forks source link

Crash when tracing programs that send nested lattices in channels #314

Open JoshRosen opened 11 years ago

JoshRosen commented 11 years ago

If I turn on tracing in the TestMarhsalNestedLattices test, Bud crashes because MsgPack cannot marshal lattices:

test_marshal(TestMarshalNestedLattices):
RuntimeError: ERROR!  #<Bud::BudDbmTable:0x007fb2d492a2f0> << ["lb_snd", 0, ["localhost", [<lmax: 0>]]] (etxt undefined method `to_msgpack' for <lmax: 0>:Bud::MaxLattice) in
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/monkeypatch.rb:51:in `to_msgpack'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/monkeypatch.rb:51:in `to_msgpack'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/storage/dbm.rb:129:in `pack'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/storage/dbm.rb:129:in `merge_tuple_to_db'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/storage/dbm.rb:187:in `insert'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/viz.rb:67:in `block in add_rows'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/viz.rb:52:in `each'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/viz.rb:52:in `add_rows'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/viz.rb:82:in `block in do_cards'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/viz.rb:76:in `each'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/viz.rb:76:in `do_cards'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud.rb:1146:in `tick_internal'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud.rb:653:in `block in run_bg'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud.rb:964:in `block in schedule_and_wait'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:250:in `call'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:250:in `block in schedule'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:959:in `call'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:959:in `block in run_deferred_callbacks'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:956:in `times'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:956:in `run_deferred_callbacks'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run_machine'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud.rb:942:in `block in start_reactor'
in
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/viz.rb:70:in `rescue in block in add_rows'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/viz.rb:66:in `block in add_rows'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/viz.rb:52:in `each'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/viz.rb:52:in `add_rows'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/viz.rb:82:in `block in do_cards'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/viz.rb:76:in `each'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud/viz.rb:76:in `do_cards'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud.rb:1146:in `tick_internal'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud.rb:653:in `block in run_bg'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud.rb:964:in `block in schedule_and_wait'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:250:in `call'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:250:in `block in schedule'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:959:in `call'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:959:in `block in run_deferred_callbacks'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:956:in `times'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:956:in `run_deferred_callbacks'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run_machine'
    /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run'
    /Users/joshrosen/Documents/cloud_programming/bud/lib/bud.rb:942:in `block in start_reactor'

In order to produce this full traceback, I had to slightly modify the exception handling in viz.rb:

diff --git a/lib/bud/viz.rb b/lib/bud/viz.rb
index 22074ca..65aba32 100644
--- a/lib/bud/viz.rb
+++ b/lib/bud/viz.rb
@@ -66,7 +66,8 @@ class VizOnline #:nodoc: all
       begin
         @logtab << newrow
       rescue
-        raise "ERROR!  #{@logtab} << #{newrow.inspect} (etxt #{$!})"
+        raise "ERROR!  #{@logtab} << #{newrow.inspect} (etxt #{$!}) in\n    " +
+          $!.backtrace.join("\n    ") + "\nin"
       end
     end
   end

This is the same problem that #295 fixed, so one solution would be to extract the fix from that commit into its own serialization wrapper that we could re-use. The other alternative would be to replace MsgPack. In either case, hiding the choice of serialization module behind our own interface would make it easier to experiment with different serializers.