Commit graph

20 commits

Author SHA1 Message Date
刘皓
f00cfdbcf5
Rework the patches for Ruby WASI memory leaks 2025-04-20 11:56:50 -04:00
刘皓
5a5fcd26c5
Delete copy constructor for stack_frame_guard and stack_frame
The copy constructors are causing problems when the `fiber.stack` vector
gets reallocated when its capacity is full, since when vectors are
reallocated, the elements are moved (or copied if there's no usable move
constructor) to the reallocated memory and then the original elements
are destroyed.

This premature calling of destructors leads to double-free and
use-after-free errors.

I fixed it by deleting the copy constructors and explicitly defining
move constructors.
2025-04-16 21:39:04 -04:00
刘皓
c7f35c96c9
Make sandbox-bindgen allocate varargs buffers on the stack
Not sure why, but this fixes crashes when calling variadic functions in
the Ruby API in libretro builds when Ruby is built without `-DNDEBUG`.
Maybe the previous way of calling varargs functions was undefined
behaviour somehow.
2025-04-14 21:04:14 -04:00
刘皓
911cfc29f5
Fix sandbox-bindgen.rb not generating bindings for functions that take no arguments 2025-04-13 22:48:58 -04:00
刘皓
35455e17dc
Apply patches from https://github.com/mkxp-z/ruby in libretro builds 2025-04-10 14:00:32 -04:00
刘皓
12f12d91a1
Apply patch from ruby/ruby#12995 in libretro builds 2025-03-31 12:28:30 -04:00
刘皓
6f6d0044ff
Decrease size of Ruby in libretro builds
This decreases the size of the libretro core by around 10% without
having a discernable effect on game compatibility.
2025-03-27 22:00:00 -04:00
刘皓
941ee73f1d
Don't set saved_ec.tag to NULL in cont_init() 2025-03-27 11:25:48 -04:00
刘皓
fac72be163
Fix a second Ruby memory leak
Okay, I think that fixes all the memory leaks. Finally! I'll submit a
pull request to Ruby to fix both of the memory leaks.
2025-03-27 00:28:37 -04:00
刘皓
82444abed2
Fix stack pointer leak in libretro builds
There's currently a memory leak in libretro builds where memory usage
increases by several kilobytes every frame you hold down an arrow key
while the player character is visible on the map in KNight-Blade.

This fixes a bug where parts of the WebAssembly stack are leaked when an
exception is caught in Ruby. There seems to be another source of memory
leaking, though, because memory usage still increases by several
kilobytes every frame like before.

I'm pretty sure this bug I fixed is an internal Ruby bug that I should
be creating a pull request to fix. I'll create one once I fully fix the
memory leak, since there might be more Ruby bugs that I have yet to
find.
2025-03-25 16:19:08 -04:00
刘皓
322d61b604
Allow adjusting Ruby GC parameters in libretro builds
There seems to be a memory leak somewhere. I'm tweaking the GC
parameters to be more conservative to help track down the leak.
2025-03-21 11:56:45 -04:00
刘皓
eeef9ff943
Don't make sandbox_malloc into a coroutine
Okay, the coroutine implementation of `sandbox_malloc` is clearly
broken. It would be working if Asyncify instrumented the `memory.grow`
WebAssembly instruction, but it doesn't instrument it.

This commit reverts commit 42c4ff9497 and
also increases the default VM memory allocation from 64 MiB to 96 MiB to
account for the lack of ability to increase the memory allocation at run
time. I'll find some new way to implement increasing the memory
allocation later.
2025-03-18 13:49:41 -04:00
刘皓
359203805c
Fix typo in libretro/Makefile 2025-03-03 18:45:31 -05:00
刘皓
20f806abef
Remove dependency on xxd 2025-02-27 23:32:30 -05:00
刘皓
ba68b8fa5b
Move libretro headers and SDL headers to meson.build 2025-02-27 20:39:17 -05:00
刘皓
5124baf23e
Retrieve RetroArch Nintendo Switch patch from GitHub 2025-02-24 01:08:00 -05:00
刘皓
9ed11ecffa
Use libretro's PlayStation 3 Docker image instead of ScummVM's 2025-02-22 16:04:51 -05:00
刘皓
71fa2453e8
Fix libretro compilation error when using GCC < 8.1.0 2025-02-21 17:56:32 -05:00
刘皓
42c4ff9497
Make sandbox_malloc into a coroutine
According to AddressSanitizer, when `sandbox_malloc` causes the
WebAssembly memory to grow in size, every single coroutine on the
sandbox stack gets corrupted. So if `sandbox_malloc` is going to cause
the memory to grow in size, we need to yield so that there are no
coroutines on the sandbox stack while the reallocation occurs.
2025-02-17 00:38:40 -05:00
刘皓
7c066a2b24
Change some of the nomenclature in libretro builds 2025-02-14 12:05:30 -05:00