9 Commits

Author SHA1 Message Date
b17397f0dd tests: derive every test's scratch folder from test_temp_dir::temp_dir, not GetTempPath (TEST-TEMPDIR-STRIPPED-ENV)
With TMP, TEMP and USERPROFILE all unset, GetTempPathW returns C:\Windows\, and the throwing create_directories/copy_file/ofstream on C:\Windows\leonida_* aborts with 0xc0000409 before the test body runs. runtime/test/test_temp_dir.h grows one entry, testfiles::temp_dir(): LEONIDA_TEST_DIR when set, the current directory when the temp environment is stripped (Windows), else the standard temp resolution. Fifty-two test files and the tiny_game fixture that called GetTempPathA/W or temp_directory_path directly now use it; d3d12_queue_handover_test.cpp also checks the _sopen_s result in capture_stderr instead of silently returning empty stderr. One runtime source function needed the same fallback because tests exercise it: tls_host_clone_dir in runtime/src/pe_loader.cpp (the loader_tls tests). Rebased onto current main after its D3D-448 additions to d3d12_mesh_test.cpp (3-way; the mesh test keeps both). Verification on a Windows VM: stripped environment - the previously crashing d3d12 tests exit 77 (no usable Vulkan device) instead of aborting, file_system_test runs all 505 checks and loader_test all 95 with zero failures; normal environment - identical outcomes; LEONIDA_TEST_DIR honored under a fully stripped environment (the scratch folder observed mid-run inside it, cleaned up after the pass). The finding is whoalin1's (coordination issue #14, 02:37:44Z).

AI-assisted.
2026-11-28 19:01:06 +00:00
7daa4a4a51 Merge pull request #664 from sodove/perf/pe-block-reads
runtime: read PE files in blocks (RT-PE-BLOCK-READ)
2026-11-28 18:59:07 +01:00
d8cfc01d51 tests: check whether the locked PE tail actually blocks CRT reads 2026-11-26 10:11:12 +05:00
2e8a92d72a runtime: guard base_reservation parsing and VirtualQuery loop overflow 2026-11-25 19:47:42 +01:00
291a96f7de runtime: read PE files in blocks (RT-PE-BLOCK-READ)
Based on the block-read proposal and Wine measurements from cobrabm12. Add a Windows regression for a read failure after a valid prefix.
2026-11-24 15:31:26 +05:00
74941a2411 base_reservation: read LEONIDA_BASE_RESERVED with swscanf_s (MSVC C4996)
swscanf at base_reservation.h:44 was the runtime build's only warning on
main 6a6704d, printed for five targets. swscanf_s takes no buffer sizes
for integer conversions, so the %llx:%llx parse is the same.

pe_loader_test now checks inherited(): a valid value, size 0, no size,
a non-hex base and no variable. Only arm64 Wine relaunches gta6rt, so a
Windows run never reached this parser before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 09:09:13 -06:00
27d1b11b64 Runtime: register each mapped image's x64 unwind table (.pdata) with RtlAddFunctionTable
Images the loader maps by hand are unknown to the system unwinder, so an exception raised in or passing through one couldn't be dispatched and killed the process. load() now validates the exception directory (entries in bounds, sorted, non-overlapping; zero-length entries allowed, as in System32's symcryptk.dll) and registers it; the loader removes it before freeing the image. Rules measured over 3,780 x64 System32 images (5,023,071 entries) and the 16 package DLLs.

Tests: loader_test covers registration, removal and six corrupt tables on hand-built images; pe_loader_test checks a fixture SEH fault is caught by the image's own handler (fails without registration) and, with LEONIDA_GAME_DIR, every package DLL's table.

AI-assisted.
2026-11-21 23:18:59 +01:00
da499ab911 Loader: initialise dependencies before their importers
map_image pushes a module into order_ before bind_imports maps the modules it
imports, so order_ lists an importer ahead of its DLLs, and initialise() ran
TLS callbacks and DllMain in that order. Keep a separate init_order_ filled
after a module's imports are loaded and initialise from it. modules() stays
mapping order. pe_loader_test checks tiny_dll comes before tiny_exe.
2026-11-21 21:07:23 +01:00
caa31b5fd2 Runtime: tests for the native PE loader (fixtures, imports, relocations) 2026-11-21 18:08:39 +00:00