Fix crash when using debug.log.

It turns out that bro -B all caused a segmentation fault since the
configuration framework was merged; this is caused by the fact that
calling the global_ids bif interacted poorly with -B all due to
side-effects that caused insertions into the global scope in the
global_ids loop.
This commit is contained in:
Johanna Amann 2019-01-31 14:34:50 -08:00
parent 49a30d61cf
commit 1ee96516e8

View file

@ -1843,6 +1843,17 @@ function global_ids%(%): id_table
TableVal* ids = new TableVal(id_table); TableVal* ids = new TableVal(id_table);
PDict(ID)* globals = global_scope()->Vars(); PDict(ID)* globals = global_scope()->Vars();
IterCookie* c = globals->InitForIteration(); IterCookie* c = globals->InitForIteration();
#ifdef DEBUG
/**
* Explanation time: c needs to be a robust cookie when one is in debug mode,
* otherwise the Zeek process will crash in ~80% of cases when -B all is specified.
* The reason for this are the RecordVals that we create. RecordVal::Assign triggers
* a StateAccess::Log, which in turn (only in debug mode) triggers StateAccess::Describe,
* which creates a UniqueID for the variable, which triggers an insert into global_scope.
* Which invalidates the iteration cookie if it is not robust.
**/
globals->MakeRobustCookie(c);
#endif
ID* id; ID* id;
while ( (id = globals->NextEntry(c)) ) while ( (id = globals->NextEntry(c)) )