[Bro-Dev] #366: Crash with optional table and record ctors

Bro Tracker bro at tracker.icir.org
Wed Jan 26 13:21:44 PST 2011


#366: Crash with optional table and record ctors
----------------------+------------------------
  Reporter:  robin    |      Owner:
      Type:  Problem  |     Status:  new
  Priority:  Normal   |  Milestone:
 Component:  Bro      |    Version:  git/master
Resolution:           |   Keywords:
----------------------+------------------------

Comment (by seth):

 >     type request: record {
 >         ...
 >         t: time;
 >         x: table[string] of string &optional &default="-";
 >         ...
 >         }
 >
 >     local req: request = [$t=network_time()];  # <-- here

 This is actually crashing because of the &default.  If you remove the
 &optional attribute, it still crashes.

 What are you trying to set to "-"?  It doesn't make much sense that you'd
 get back a table like this:

 {{{
 [ ["-"] = nil ]
 }}}

 Of course Bro doesn't have a nil value anyway, but you get the idea.  The
 use of the &default attribute on complex types in records has never been
 very well defined and I think this is one of the cases where things need
 handled differently.  It occurs to me that I should be able to provide the
 default attribute something like this:

 {{{
 x: table[string] of string &default = table(["-"] = "<empty>");
 }}}

 I know that would cause some problems with execution time and is why
 table() and set() can't be used as default attributes yet, but it should
 definitely work.  I think that has been one of my largest annoyances about
 the scripting language overall.

-- 
Ticket URL: <http://tracker.icir.org/bro/ticket/366#comment:0>
Bro Tracker <http://tracker.icir.org/bro>
Bro Issue Tracker



More information about the bro-dev mailing list