otya128 / winevdm

16-bit Windows (Windows 1.x, 2.x, 3.0, 3.1, etc.) on 64-bit Windows
GNU General Public License v2.0
2.67k stars 152 forks source link

wheapwlk display a lot of empty global heap entries #806

Open X547 opened 4 years ago

X547 commented 4 years ago

Version: otvdm-master-1861

wheapwlk.exe is a part of OpenWatcom package, sources available. OpenWatcom can be downloaded at http://www.openwatcom.org/download.php. stress.dll is required to run.

As can be visible at screenshot, a lot of empty global heap entries are displayed. Is slow down list refreshing a lot. Issue is not present in Windows 3.11 in DosBox. Issue is likely caused by inaccurate heap walk API (https://github.com/otya128/winevdm/blob/master/toolhelp/toolhelp.c). There are also other issues such as improper heap object flags, failure of local heap detection.

This tool is useful to understand and debug inner workings of Win16 runtime environment and it will be nice no make it work properly.

wheapwlk
X547 commented 4 years ago

heap (win 3.1).TXT heap (winevdm-1861).txt

cracyc commented 3 years ago

There are also other issues such as improper heap object flags, failure of local heap detection.

The winevdm global heap isn't compatible with the win31 global heap. Many heap objects are shown and viewable so heap walking works even if somewhat differently. The watcom source is available so the flags might be able to be added if what heap walk expects were determined.

X547 commented 3 years ago

NTVDM from Windows 8.1 also works fine. Issue can be fixed by skipping entries with zero pArena->base in GlobalNext16. GLOBAL_FREE handling is also wrong, it should return free memory blocks with non-zero size and GT_FREE block type, not empty table entries.

This is documented behavior and other debugging utilities also depend on this behavior.

heap (ntvdm windows 8.1).TXT

X547 commented 3 years ago

Toolhelp documentation is available in "Windows 3.1 reference guide" by Borland.