- Test Date: 2025-10-28
- dmffs Version: Latest from repository
- dmod Version: From dmvfs dependency
- Test Platform: fs_tester from dmvfs
File: src/system/public/dmod_dmf_api.c
Changes:
- Added validation for API counts (< 1000)
- Added NULL pointer checks for API sections
- Added NULL check for signature pointers
Result: ❌ FAILED - Crash still occurs
Analysis: Safety checks passed but crash happened anyway. The issue is more fundamental - accessing Entries[j] structure itself causes the crash, not reading the Signature field.
File: src/system/public/dmod_dmf_api.c
Changes:
- Added pointer address range validation (0x1000 - 0x7FFFFFFFFFFF)
- Skips entries with suspicious pointers
Result: ❌ FAILED - Crash still occurs before range check
Analysis: The crash happens when accessing InputsApi->InputSection->Entries[j] itself, before we can read the .Signature field.
The crash is NOT in the comparison logic but in how the Entries array is accessed. The issue appears to be:
- Array bounds corruption: The
numberOfInputsreports 61 entries, but the actual allocated array might be smaller - Memory layout issue: In complex multi-module environments (dmvfs + dmfsi + dmffs), the API entries array memory layout may be incorrect
- Uninitialized memory: The
Entriesarray pointer might be pointing to partially initialized or corrupt memory
[VERBOSE] Connected: DMOD_IsFunctionConnected@Dmod:1.0 0x0040A5D5
[VERBOSE] Connected: DMOD_Printf@Dmod:1.0 0x0040B187
[VERBOSE] Connected: DMOD_GetEnv@Dmod:1.0 0x0040BB5F
[VERBOSE] Connected: DMOD_ReadMemory@Dmod:1.0 0x0040AF59
[VERBOSE] Connected: DMOD_Free@Dmod:1.0 0x0040AD6D
[VERBOSE] Connected: DMOD_Malloc@Dmod:1.0 0x0040AC43
<< SEGFAULT >>
Successfully connects 6 APIs, crashes on ~7th iteration when j reaches a certain index while iterating through 61 input entries.
- Investigate
Dmod_Api_GetNumberOfEntries(): Check if this function correctly calculates the number of entries based on section size - Check memory allocation: Verify that the
Entriesarray is properly allocated for all 61 entries - Add array bounds checking: Before accessing
Entries[j], verify thatj * sizeof(Entry) < SectionSize - Review module loading: Check if API sections are properly initialized during module loading in multi-module scenarios
The provided patches add defensive checks but do not fix the underlying issue. The problem requires deeper investigation into:
- How API entry counts are calculated
- How the Entries array is allocated and initialized
- Why it works in simple environments (dmod_loader) but fails in complex ones (dmvfs)
The issue is in dmod's API management, specifically in how it handles API entries when multiple modules are loaded simultaneously.