Skip to content

Commit 1c9bb44

Browse files
committed
Ignore backward jumps in computing serializer size
When defining a new topic, typically the serializer instructions that are usually in constant memory and generated by the IDL compiler are copied into memory managed by the Cyclone implementation. For this it needs to compute the size of the serializer, which the IDL compiler doesn't provide. It does this by effectively dry-running the program. (Note that it doesn't validate the program.) All but the JSR operations move the program counter forward, but the JSR operation can cause it to go backward instead and allows implementing recursive types (the IDL compiler doesn't support them, but one might decide to work around that limitation). When dry-running the program, following a backwards jump can cause a non-terminating loop. The jump could potentially be to an unexplored address and so ignoring all backwards jumps potentially means it skips part of the program. As this is not a validator and the program can always be arranged so that a following a backwards jump is not relevant to computing the size correctly, this is reasonable approximation. Signed-off-by: Erik Boasson <[email protected]>
1 parent 7553f09 commit 1c9bb44

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/core/ddsi/src/ddsi_cdrstream.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ static void dds_stream_countops1 (const uint32_t * __restrict ops, const uint32_
364364
break;
365365
}
366366
case DDS_OP_JSR: {
367-
dds_stream_countops1 (ops + DDS_OP_JUMP (insn), ops_end);
367+
if (DDS_OP_JUMP (insn) > 0)
368+
dds_stream_countops1 (ops + DDS_OP_JUMP (insn), ops_end);
368369
ops++;
369370
break;
370371
}

0 commit comments

Comments
 (0)