CKB Pulse

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)

More about Developer tooling

All 35 in this topic

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.

Drawn from public commits and checked against the commit each one came from and the project's code today. Read the source before you rely on one. Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. Want a lesson changed or removed? Open an issue.