Open sixlettervariables opened 6 years ago
The problem occurs because of dotkernel has a reference field dotcontext
Simple changing from reference to value fixes the problem, but i'm not 100% sure that it preserves the correct semantics of dotkernel. Hope @CBaquero will check and fix it in the right way.
I ran into a crash while walking through the example code in Visual Studio, and was able to get some help from the VC++ team in tracking it down:
https://github.com/CBaquero/delta-enabled-crdts/blob/master/delta-crdts.cc#L416-L427
res
is created on the stack, which ends up using the stack allocatedres.cbase
when assigning the reference tores.c
in the ctor.https://github.com/CBaquero/delta-enabled-crdts/blob/master/delta-crdts.cc#L312-L315
Once
res
is copied by value on return the stack allocated value is destroyed andc
is left with a dangling reference and an eventual crash. I'm not proficient enough in C++ to advise on a fix, but figured I'd pass this along.The crash occurs in
ccounter::inc
whenr.dk
joins the result ofdk.add
ordk.rmv
: https://github.com/CBaquero/delta-enabled-crdts/blob/master/delta-crdts.cc#L670-L687