Fix segfault: uninitialized identifiers w/ &synchronized (addresses #66)

Synchronization of state between connecting peers now skips over
identifiers that aren't initialized with a value yet.  If they're
assigned a value later, that will be synchronized like usual.
This commit is contained in:
Jon Siwek 2012-12-05 12:36:09 -06:00
parent 32239ea633
commit f403e537ec
4 changed files with 18 additions and 3 deletions

View file

@ -1032,6 +1032,14 @@ bool RemoteSerializer::SendAllSynchronized(Peer* peer, SerialInfo* info)
for ( ; index < sync_ids.length(); ++index )
{
if ( ! sync_ids[index]->ID_Val() )
{
#ifdef DEBUG
DBG_LOG(DBG_COMM, "Skip sync of ID with null value: %s\n",
sync_ids[index]->Name());
#endif
continue;
}
cont->SaveContext();
StateAccess sa(OP_ASSIGN, sync_ids[index],

View file

@ -31,3 +31,4 @@ file "test2" of string
6667/tcp
[2, 20, 3, 4]
[a=zxzxzx, b=[a=pop, b=43, c=9.999], c=[a=IOIOI, b=201, c=612.2], d=6.6666, e=<uninitialized>]
122112

View file

@ -31,3 +31,4 @@ file "test2" of string
6667/tcp
[2, 20, 3, 4]
[a=zxzxzx, b=[a=pop, b=43, c=9.999], c=[a=IOIOI, b=201, c=612.2], d=6.6666, e=<uninitialized>]
122112

View file

@ -1,7 +1,7 @@
# @TEST-SERIALIZE: comm
#
# @TEST-EXEC: btest-bg-run sender bro %INPUT ../sender.bro
# @TEST-EXEC: btest-bg-run receiver bro %INPUT ../receiver.bro
# @TEST-EXEC: btest-bg-run sender bro -b %INPUT ../sender.bro
# @TEST-EXEC: btest-bg-run receiver bro -b %INPUT ../receiver.bro
# @TEST-EXEC: btest-bg-wait 20
#
# @TEST-EXEC: btest-diff sender/vars.log
@ -27,6 +27,7 @@ global foo13 = { [1,"ABC"] = 101, [2,"DEF"] = 102, [3,"GHI"] = 103 } &persiste
global foo14 = { [12345] = foo11, [12346] = foo11 } &persistent &synchronized;
global foo15 = 42/udp &persistent &synchronized;
global foo16: vector of count = [1,2,3] &persistent &synchronized;
global foo18: count &persistent &synchronized; # not initialized
type type1: record {
a: string;
@ -70,6 +71,7 @@ event bro_done()
print out, foo15;
print out, foo16;
print out, foo17;
print out, foo18;
}
@ -128,7 +130,8 @@ function modify()
delete foo17$e;
foo2 = 1234567;
}
foo18 = 122112;
}
@load frameworks/communication/listen
@ -148,6 +151,8 @@ redef Communication::nodes += {
@TEST-START-FILE receiver.bro
@load base/frameworks/communication
event bro_init()
{
capture_events("events.bst");