[Bro-Dev] #946: Async scriptland functions stack explosion

Bro Tracker bro at tracker.bro-ids.org
Fri Feb 15 10:26:33 PST 2013


#946: Async scriptland functions stack explosion
----------------------+------------------------
  Reporter:  seth     |      Owner:
      Type:  Problem  |     Status:  new
  Priority:  Medium   |  Milestone:  Bro2.2
 Component:  Bro      |    Version:  git/master
Resolution:           |   Keywords:
----------------------+------------------------

Comment (by jsiwek):

 This patch may work around the issue:

 {{{
 diff --git a/scripts/base/frameworks/notice/actions/drop.bro
 b/scripts/base/fram
 index 0116dd4..0a6ee7e 100644
 --- a/scripts/base/frameworks/notice/actions/drop.bro
 +++ b/scripts/base/frameworks/notice/actions/drop.bro
 @@ -17,20 +17,19 @@ export {
         };
  }

 +function drop_func(n: Notice::Info)
 +       {
 +       if ( ACTION_DROP !in n$actions ) return;
 +
 +       #local drop = React::drop_address(n$src, "");
 +       #local addl = drop?$sub ? fmt(" %s", drop$sub) : "";
 +       #n$dropped = drop$note != Drop::AddressDropIgnored;
 +       #n$msg += fmt(" [%s%s]", drop$note, addl);
 +       }
 +
  # This is a little awkward because we want to inject drop along with the
  # synchronous functions.
  event bro_init()
         {
 -       local drop_func = function(n: Notice::Info)
 -               {
 -               if ( ACTION_DROP in n$actions )
 -                       {
 -                       #local drop = React::drop_address(n$src, "");
 -                       #local addl = drop?$sub ? fmt(" %s", drop$sub) :
 "";
 -                       #n$dropped = drop$note !=
 Drop::AddressDropIgnored;
 -                       #n$msg += fmt(" [%s%s]", drop$note, addl);
 -                       }
 -               };
 -
         add Notice::sync_functions[drop_func];
         }
 }}}

 I don't know the intention of the original code, but I think that refactor
 is equivalent in that it still does nothing...

 As for the reason why that fixes the unrelated example code... it goes
 something like:

 1) Event (or hook) handlers share a frame.
 2) The bro_init handler in the example script has a when block which
 causes its frame to be cloned.
 3) The cloning of the bro_init handler's frame starts serializing the
 value of the local drop_func variable which is an anonymous-function
 4) That serialization never ends, looks like maybe an infinite loop of
 "serialize anonymous-function ID" ->"serialize function value bound to ID"
 -> "serialize ID of function".

 Haven't played with fixes for that last step yet, but maybe the workaround
 is enough to unblock you.

-- 
Ticket URL: <http://tracker.bro-ids.org/bro/ticket/946#comment:1>
Bro Tracker <http://tracker.bro-ids.org/bro>
Bro Issue Tracker



More information about the bro-dev mailing list