git: 9front

Download patch

ref: 822821cdb002c4996e0c69322a6ec51cae45d34c
parent: 664b66d6342e389052f084bbbc8dab7e6c196ddb
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Aug 13 18:12:20 EDT 2022

dtracy: correctly look up aggregate keys

the ANode struct contains a variable sized buffer for the key,
however when we created and copied the aggregate, we used struct
assignment to initialize the node. the struct assignment only
knows about the fixed size portion of the struct, and did not
copy the key, which mean that key lookups would fail, and we would
insert a new value into the aggregation every time, both leaking
the memory and producng incorrect results.

--- a/sys/src/cmd/dtracy/agg.c
+++ b/sys/src/cmd/dtracy/agg.c
@@ -93,7 +93,7 @@
 		np = (ANode *) avllookup(tp, key, 0);
 		if(np == nil){
 			np = emalloc(sizeof(ANode) - 1 + a->keysize);
-			*np = *key;
+			memcpy(np, key, sizeof(ANode) - 1 + a->keysize);
 			createrecord(a->type, np, (s64int*)&p[8+a->keysize]);
 			avlinsert(tp, np);
 		}else
--