All lessons · Developer tooling · Start here · Glossary
Mock syscalls must write back output lengthAdvancedFrom one fix
From one fix · Check: right · Checked 2026-11-19
When a ckb-vm mock or fuzzing syscall layer implements inherited_fds, it must store the fd count back into length_addr with store64 after writing the fd buffer. Otherwise the script reads back the capacity it passed in and treats unwritten slots as fds. ckb-vm-contrib's fuzzing utils lacked this until v1.1.2.
Why it matters: Without the write back, a script running under the mock sees the capacity it passed in as the fd count and diverges from real CKB behaviour.
Pattern
syscall handler writes data to the buffer but never calls machine.memory_mut().store64(&length_addr, wrote_length)- Concepts
- Testing and devnet
- Evidence
- From one fix: from one project, checked against its commit
- First seen
- 2026-11-16
- Last changed
- 2026-11-16
- Last checked
- 2026-11-19
- Check against the commit
- right: the lesson follows from its commit and still holds in the code today
Sources (1)
- 2026-11-16 · nervosnetwork/ckb-vm-contrib · more from this project
More about Developer tooling
- ckb-vm-js 0.2.0 (npm) checks header hash instead of rejecting the field
- Derive devnet Spore and system script cell deps from a fresh OffCKB export
- Pass wasm bytes to ckb-vm-js createVerifier in Node
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
LusoCryptoLabs, "Mock syscalls must write back output length", CKB lessons, https://pulse.lusocryptolabs.com/learned/tooling/mock-syscalls-must-write-back-output-length, CC BY 4.0, last changed 2026-11-16.