From 1ee96516e84dd7a4245413d468709af6b6029f8e Mon Sep 17 00:00:00 2001 From: Johanna Amann Date: Thu, 31 Jan 2019 14:34:50 -0800 Subject: [PATCH] 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. --- src/bro.bif | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/bro.bif b/src/bro.bif index 13b2b9aa2e..d07fddc3b0 100644 --- a/src/bro.bif +++ b/src/bro.bif @@ -1843,6 +1843,17 @@ function global_ids%(%): id_table TableVal* ids = new TableVal(id_table); PDict(ID)* globals = global_scope()->Vars(); 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; while ( (id = globals->NextEntry(c)) )