In iOS Shortcuts, sometimes after you have saved a program and then you run it or look at it later, you discover a certain amount of garbage code at the end as if appended. My best guess is that it sometimes saved an entire block, packet, or alloc cell and gets the length wrong, always overestimating it. The idea is that block or alloc cell’s total length is used rather than the length of the valid data in it, and I’m thinking that it saves uninitialised garbage bytes which are interpreted as Shortcuts opcodes. Why it happens only sometimes is a total mystery though. It could be when it syncs programs in the iCloud, but I’m not at all sure. Or maybe it’s the editor getting the length wrong on a save.
Deleting the garbage off the end is an effective workaround. When you run a duff program affected in this way, it really does perform bizarre actions according to the garbage opcodes seen in the editor later, so it’s very serious. Valid code is never lost, so the length seems never to be too short. That is surprising, and very fortunate.
It is amazing that the developers have never seen this, because it isn’t extremely rare.