Stage D batch 1: fix silent error sites in repl.c and inference_words.c (FABRIC-3.md §XXXII.6)
repl.c's sk_word_blk_attach_ack() and inference_words.c's array_ptr() helper + infer_word_run()'s allocation guard now log a diagnostic via log_message(LOG_ERROR, ...) before setting vm->error, matching defer_words.c's own gold-standard pattern (§XXXII.3) -- these are internal/background conditions (a malformed message-callback, a bad array reference or allocation failure), not interactive usage mistakes, so the fix keeps the fault and reports it rather than dropping it like USE's own fix did. Batched together (4 sites total, smaller combined than the next file) rather than two separate acceptance cycles for negligible size. Three-arch clean qemu acceptance passed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BWpNjdwPtFLuVLaAq44L9K
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
09959c6ca2
commit
5417ffb2bf
@@ -228,7 +228,11 @@ static sk_blk_attach_pending_t *g_blk_attach_pending = (void *)0;
|
||||
* failed blk_subsys_attach_device() call, and simply never births
|
||||
* anything for this attach. */
|
||||
static void sk_word_blk_attach_ack(VM *vm) {
|
||||
if (vm->dsp < 1) { vm->error = 1; return; }
|
||||
if (vm->dsp < 1) {
|
||||
log_message(LOG_ERROR, "BLK-ATTACH-ACK: stack underflow");
|
||||
vm->error = 1;
|
||||
return;
|
||||
}
|
||||
cell_t ok_flag = vm_pop(vm);
|
||||
cell_t dev_addr = vm_pop(vm);
|
||||
blkio_dev_t *dev = (blkio_dev_t *)(uintptr_t)dev_addr;
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
|
||||
#include "vm.h"
|
||||
#include "word_registry.h"
|
||||
#include "log.h"
|
||||
#include "q48_16.h"
|
||||
#include "inference_engine.h"
|
||||
#include "ssm_jacquard.h"
|
||||
@@ -74,11 +75,15 @@ static inline double q48_to_dbl(q48_16_t q) { return (double)q / 65536.0; }
|
||||
static const uint64_t *array_ptr(VM *vm, vaddr_t addr, cell_t u)
|
||||
{
|
||||
if (u <= 0 || addr >= (vaddr_t)VM_MEMORY_SIZE) {
|
||||
log_message(LOG_ERROR, "inference: bad array reference (addr=%lu u=%ld)",
|
||||
(unsigned long)addr, (long)u);
|
||||
vm->error = 1;
|
||||
return NULL;
|
||||
}
|
||||
size_t bytes = (size_t)u * sizeof(cell_t);
|
||||
if ((size_t)addr + bytes > VM_MEMORY_SIZE) {
|
||||
log_message(LOG_ERROR, "inference: array reference out of bounds (addr=%lu u=%ld)",
|
||||
(unsigned long)addr, (long)u);
|
||||
vm->error = 1;
|
||||
return NULL;
|
||||
}
|
||||
@@ -139,7 +144,11 @@ static void infer_word_run(VM *vm)
|
||||
/* Allocate outputs struct if not yet done */
|
||||
if (!vm->last_inference_outputs) {
|
||||
vm->last_inference_outputs = (InferenceOutputs *)sf_malloc(sizeof(InferenceOutputs));
|
||||
if (!vm->last_inference_outputs) { vm->error = 1; return; }
|
||||
if (!vm->last_inference_outputs) {
|
||||
log_message(LOG_ERROR, "INFER-RUN: allocation failed for InferenceOutputs");
|
||||
vm->error = 1;
|
||||
return;
|
||||
}
|
||||
memset(vm->last_inference_outputs, 0, sizeof(InferenceOutputs));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user