mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 06:09:58 -04:00
Answer NVN getters asked of no object with 0, and map a buffer with no pool to memory of its own.
The game's scene-loading thread makes a few NVN calls with a null object while an area loads or Kakariko's time of day changes: a memory pool's flags (and the other pool getters), a texture builder's storage size or alignment, and the mapping of a buffer that has no pool, into which it then writes 0x3d0 bytes. Each read the object at address 0 plus a field's offset, an access violation. The pool getters, nvnMemoryPoolInvalidateMappedRange and the two builder queries now answer 0 for a null object (nvn_no_object), and nvnBufferMap of a buffer with no pool returns a block of scratch memory (64 KiB, or the buffer's size when it records a larger one) instead of 0. The first such calls are logged with their caller. These fit the crash reports in Castle Town and in Kakariko before Death Mountain (#605, #602), which have not been confirmed to be this. Checked: --probe-nvn gains three checks (pool getters of no pool, builder queries of no builder, a 0x3d0-byte write through the mapping of a buffer with no pool) and they pass; its four other failures are the same on the baseline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
// back end's images) back first. NX2navi invalidates its 260x260 R16 grass maps and 1x1 pick targets this way. A
|
||||
// CPU-invisible pool has no storage to read.
|
||||
void nvn_pool_invalidate(const pool_t *p, uint64_t off, uint64_t size) {
|
||||
if (!p->mem || nvn_gpu_only((uintptr_t)p->mem) || off >= p->size || !size) return;
|
||||
if (!p || !p->mem || nvn_gpu_only((uintptr_t)p->mem) || off >= p->size || !size) return;
|
||||
if (size > p->size - off) size = p->size - off;
|
||||
gfx_backend()->guest_read((uintptr_t)p->mem + off, size);
|
||||
}
|
||||
@@ -63,7 +63,10 @@ NVN_API(nvnDeviceGetTimestampInNanoseconds) { ret_x(c, ticks_to_ns(((const NVNco
|
||||
|
||||
// ---------- memory pools and buffers
|
||||
// size_t nvnMemoryPoolGetSize(const NVNmemoryPool *p)
|
||||
NVN_API(nvnMemoryPoolGetSize) { ret_x(c, ((const pool_t *)arg_p(c, 0))->size); }
|
||||
NVN_API(nvnMemoryPoolGetSize) {
|
||||
if (nvn_no_object(c, "nvnMemoryPoolGetSize")) return;
|
||||
ret_x(c, ((const pool_t *)arg_p(c, 0))->size);
|
||||
}
|
||||
// void nvnMemoryPoolInvalidateMappedRange(const NVNmemoryPool *p, ptrdiff_t offset, size_t size)
|
||||
NVN_API(nvnMemoryPoolInvalidateMappedRange) {
|
||||
int64_t off = (int64_t)arg_x(c, 1);
|
||||
|
||||
Reference in New Issue
Block a user