CKB Pulse

Todas as lições · Rust scripts and ckb-std · Começa aqui · Glossário

CKB VM2 READ and INHERITED_FDS syscalls take a length pointer and return status in a0AvançadoDe uma correção

De uma correção · Verificação: certa · Verificada em 2026-11-19

In CKB VM2, READ takes (fd, buffer_addr, length_addr) and INHERITED_FDS takes (buffer_addr, length_addr), with *length_addr set to the buffer capacity before the ecall. The syscall returns only a status in a0 (0 on success) and writes the delivered byte count or fd count back through length_addr, so never treat a0 as the payload. After checking a0, handle short pipe reads by looping or failing explicitly, and bounds-check an INHERITED_FDS index against the smaller of the returned count and the capacity you passed.

Porque importa: A bare ecall passes garbage in a1/a2 and returns the status word as if it were the data, so the script reads wrong values or faults.

Padrão

Preferir
// READ takes (fd, buffer_addr, length_addr): the scheduler writes the payload to the buffer and the delivered byte count back through length_addr, with SUCCESS in a0.

Tirado do commit, encurtado.

Um teste mudou no mesmo commit

Está ao lado da correcção. Nós não o corremos.

Conceitos
Other
Evidência
De uma correção: de um projeto, verificada contra o commit
Vista pela primeira vez
2026-10-29
Última mudança
2026-10-29
Última verificação
2026-11-19
Verificação contra o commit
certa: a lição sai do commit e continua a valer no código de hoje

Fontes (1)

Mais sobre Rust scripts and ckb-std

Ver as 35 deste tema

Manténs um projeto de onde esta lição veio? Confirma ou corrige

Citar esta lição
LusoCryptoLabs, "CKB VM2 READ and INHERITED_FDS syscalls take a length pointer and return status in a0", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/ckb-vm2-read-and-inherited-fds-syscalls-take-a-length-pointe, CC BY 4.0, last changed 2026-10-29.

Tiradas de commits públicos e verificadas contra o commit de onde cada uma veio e o código de hoje do projeto. Lê a fonte antes de confiar numa. Texto sob CC BY 4.0: dá crédito à LusoCryptoLabs, CKB lessons, com uma ligação para a lição. Queres que uma lição seja mudada ou retirada? Abre um issue.