Commit Graph
28 Commits
Author SHA1 Message Date
Paul Gilbert 41d87f2178 M4: Cleanup of dead machine code, deleting of dead machines between scenes 2024-02-24 12:05:22 -08:00
antoniou79 a6929c4882 M4: Attempt to workaround double free() issue
In some cases the engine may access unallocate space or do a double free_mem on an "machine" object

This can happen when a script "machine"'s step triggers a callback that can result to killing the machine itself (via terminateMachineAndNull()) and free its allocated space via a different pointer, but the code in the machine's step continues to try and access the machine's now unallocated space with its original pointer.

This can be observed by running valgrind with scummvm on Linux. Otherwise crashes may occur in Linux and mingw-w64 release mode builds.

An example case is when Wilbur runs on the hamster wheel on the bottom level of the gerbil case (room602).

The proposed solution here is a workaround, based on valgrind's output, and probably does a poor job of cleaning "machine" memory that's no longer used.
More knowledge on the engine's workings is required for a proper and more efficient fix.

The workaround skips full deallocation of a machine object (in the shutdownMachine()), until the ws_KillMachines() is called. The machID field value of 0xdeaddead is used to skip the machine (which remains in the chain). A more efficient fix could do a full deallocation of a machine object earlier (and remove it from the chain like the previous code did), thus avoiding cluttering of the machine's chain.
2024-02-24 12:05:22 -08:00
Paul Gilbert 6ac2b368b3 M4: RIDDLE: Compilation fix 2024-01-16 20:46:08 -08:00
Paul Gilbert ad029b18cf M4: RIDDLE: Start of room 201 2024-01-16 17:57:12 -08:00
Eugene Sandulenko 2b7934eb85 M4: Fix endless loop 2023-12-24 02:17:14 +01:00
Paul Gilbert 003d6ca0b3 M4: Remainder of room 801 daemon 2023-12-24 01:53:38 +01:00
Paul Gilbert 3e24d2c8d2 M4: Fixing casts to intptr 2023-12-24 01:53:38 +01:00
Paul Gilbert e03a38712b M4: In progress room 105 daemon 2023-12-24 01:53:38 +01:00
Paul Gilbert caec8484c0 M4: Change lots of methods to be camelcase 2023-12-24 01:53:38 +01:00
Paul Gilbert 11d155d7ba M4: Change %ld in string formats to %d 2023-12-24 01:53:38 +01:00
Paul Gilbert d503f712ed M4: Fixes closing game menu 2023-12-24 01:53:38 +01:00
Paul Gilbert 7d537e1b33 M4: Implemented room 901 2023-12-24 01:53:38 +01:00
Torbjörn Andersson cce9e26643 M4: Use intptr instead of intptr_t, like most our engines do
If it turns out to be necessary to use intptr_t after all, we're going
to have to include the appropriate header for it. Currently we don't.
2023-12-24 01:53:38 +01:00
Paul Gilbert c47f9dc3b7 M4: Minor cleanups and pointer casting 2023-12-24 01:53:38 +01:00
Paul Gilbert 41e8a945fd M4: Fix screenCodes type in CycleEngines/ws_DoDisplay 2023-12-24 01:53:38 +01:00
Paul Gilbert 57860d338f M4: Simplify globals array holding pointers, gr_series.cpp sysfile pointer 2023-12-24 01:53:38 +01:00
Paul Gilbert f8d0c88756 M4: Fix various pointer casts to ints 2023-12-24 01:53:38 +01:00
Paul Gilbert c5777ab224 M4: Formatting fixes 2023-12-24 01:53:38 +01:00
Paul Gilbert 96bd0dd735 M4: Adding stream break methods 2023-12-24 01:53:38 +01:00
Paul Gilbert fd4e2883b1 M4: Implementing lots of wscript and dependencies
Oh, soooo many dependencies.
2023-12-24 01:53:38 +01:00
Paul Gilbert 51ee74786b M4: Change existingi Globals class to Vars class
The M4 engine has it's own globals array and constants,
so it was cleaner to have it remain as Globals, and change
the ScummVM Globals class to Vars to disambiguate it
2023-12-24 01:53:38 +01:00
Paul Gilbert d6c9d98617 M4: Beginnings of hotkey handlers, support code 2023-12-24 01:53:38 +01:00
Paul Gilbert 9e0cf325f7 M4: Remaining WS init 2023-12-24 01:53:38 +01:00
Paul Gilbert b572cd9dfb M4: Added WS Kill machines 2023-12-24 01:53:38 +01:00
Paul Gilbert 31bf3feda0 M4: Added WS Hal init/shutdown 2023-12-24 01:53:38 +01:00
Paul Gilbert 31f06d9635 M4: Added WS Cruncher init/shutdown 2023-12-24 01:53:38 +01:00
Paul Gilbert 8aca4045f6 M4: Adding wscript general init/shutdown 2023-12-24 01:53:38 +01:00
Paul Gilbert a183b57fc2 M4: Added WS load init/shutdown 2023-12-24 01:53:38 +01:00