Commit Graph

16359 Commits

Author SHA1 Message Date
John Bampton 903baddb03 Add macOS 15 to the build
macOS 15 (Sequoia) is now available as a public beta in GitHub Actions

https://github.com/actions/runner-images/issues/10686

https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
2024-11-02 12:50:17 +10:00
Yukihiro "Matz" Matsumoto 16ae9e6ed9 Merge pull request #6397 from wataash/boxno-set-value 2024-11-01 11:11:39 +09:00
Wataru Ashihara b1d299f88b boxing_no.h: rename BOXNIX_SET_VALUE -> BOXNO_SET_VALUE
boxing_nix.h was renamed to boxing_no.h on
https://github.com/mruby/mruby/commit/df4c298e3b280b11add8502f1602cefc246655dd
2024-10-31 16:01:05 +09:00
Yukihiro "Matz" Matsumoto 3885e14049 mruby-rational: explicitly add return for error cases too 2024-10-31 14:06:10 +09:00
Yukihiro "Matz" Matsumoto 19d3620965 mruby-bigint (mrb_bint_powm): stop a warning for no return 2024-10-31 14:06:10 +09:00
Yukihiro "Matz" Matsumoto 49525fa207 mempool.c: renamed from pool.c
To avoid confusion with pools in irep, we renamed region-based memory
manager from pool to mempool.

- rename pool.c to mempool.c
- separate mempool.h
- rename all mrb_pool to mrb_mempool

So if someone is using pool.c functions (I suppose no one does though),
they need to rename all `mrb_pool` to `mrb_mempool` and include
`mruby/mempool.h` header at the top.
2024-10-31 14:06:10 +09:00
Yukihiro "Matz" Matsumoto 62ef5db13e irep.h: rename mrb_pool_value to mrb_irep_pool
mrb_pool_value is a structure that represents a value in the irep
literal pool and is unrelated to mrb_pool, which performs region-based
memory management. It has been renamed mrb_irep_pool to avoid confusion.
2024-10-29 20:34:53 +09:00
Yukihiro "Matz" Matsumoto 2436b32f1f irep.h: reformat comments 2024-10-29 20:34:52 +09:00
Yukihiro "Matz" Matsumoto 6ad6b6c6c1 Merge pull request #6396 from vickash/milkvduo 2024-10-28 10:42:51 +09:00
vickash 8fbc809614 milkvduo: update GPIO gem url 2024-10-27 17:37:33 -04:00
Yukihiro "Matz" Matsumoto cda7b56d65 Merge pull request #6395 from dearblue/to_proc 2024-10-27 21:14:48 +09:00
dearblue a7a81aa761 Storing method-id inside Symbol#to_proc
When called in combination with a method like `*_eval` or `*_exec` that switches self, `__send__` was passed an object that was not necessarily a symbol as the method name.

This problem was discovered during the #6389 correction process.
2024-10-27 10:41:51 +09:00
Yukihiro "Matz" Matsumoto 38487f2100 Merge pull request #6393 from dearblue/mrb_object_exec 2024-10-26 07:51:55 +09:00
dearblue 94290b9bb8 Follow-up to #6391
The #6392 has been merged, so the call to `mrb_yield_with_class()` is no longer needed.
2024-10-25 21:11:07 +09:00
Yukihiro "Matz" Matsumoto ba69f36d6d Merge pull request #6392 from dearblue/mrb_exec_irep 2024-10-25 07:12:05 +09:00
Yukihiro "Matz" Matsumoto 49b9db24b2 Merge pull request #6391 from dearblue/instance_exec 2024-10-25 07:09:44 +09:00
dearblue 8d64788cbf Fix argument forwarding in mrb_exec_irep()
C to Ruby calls using `mrb_exec_irep()` were not forwarding arguments.

There was also a problem in setting the target class and method ID, which is also fixed.

This issue was discovered during the work to fix #6389.
2024-10-24 22:33:18 +09:00
dearblue a196d8a5f3 Fixed also argument forwarding in class_exec
Pointed out by @matz.
https://github.com/mruby/mruby/pull/6391#issuecomment-2433662139
2024-10-24 22:05:59 +09:00
dearblue f9151e0bd9 Fixed argument forwarding in instance_exec
However, on C, there is no easy way to pass keyword arguments.
Therefore, when called `Kernel#instance_exec` on C, keyword arguments are converted to positional arguments.
This is a limitation of current mruby.

fixed #6389
2024-10-24 21:20:46 +09:00
Yukihiro "Matz" Matsumoto f245943aed mruby-bigint (mrb_bint_powm): fixed bugs in type casting 2024-10-24 07:21:12 +09:00
Yukihiro "Matz" Matsumoto 0b96f7f2f7 mruby-bigint (mrb_bint_to_s): add uzero_p() check 2024-10-24 07:20:24 +09:00
Yukihiro "Matz" Matsumoto c5565a37ac mruby-bigint: add checks for divided by zero by sizes and contents 2024-10-24 07:18:34 +09:00
Yukihiro "Matz" Matsumoto 5e9593e285 mruby-bigint (udiv): add assertion for divided by zero 2024-10-24 07:16:32 +09:00
Yukihiro "Matz" Matsumoto 3d3aa92649 Merge pull request #6390 from dearblue/mrb_gc_free_gv 2024-10-23 10:03:16 +09:00
dearblue be9431a9ef Fix use-after-free by mrb_gc_unregistor()
Calling `mrb_gc_unregistor()` from `mrb_data_type::dfree` caused a use-after-free deep inside `mrb_close()`.
The impetus to investigate was <https://github.com/mruby/mruby/pull/6342#pullrequestreview-2292747530>.

Currently, when `mrb_close()` is called, all objects are destroyed first.
The process is done heap page by heap page, and when all objects belonging to a heap page are destroyed, the heap page is released.
If the next heap page contains `RData` objects, the `mrb_gc_unregistor()` function may be called from the `mrb_data_type::dfree` function.
At this time, the `mrb_gc_unregistor()` function gets an array object from a Ruby global variable.
If the array object belongs to a freed heap page, use-after-free is established by referencing this array object.

About the fixes.

First of all, there is the fact that the `mrb_gv_get()` function returns `nil` if `mrb->globals` is `NULL`.
Therefore, before destroying all objects, free `mrb->globals` and set `mrb->globals` to `NULL` at the same time.
Now the `mrb_gv_get()` function will return `nil` to the calling `mrb_gc_unregistor()` function and `mrb_gc_unregistor()` will do nothing more.

ref. https://github.com/mruby/mruby/issues/4618
2024-10-22 22:57:49 +09:00
Yukihiro "Matz" Matsumoto b95ca53e5c mruby-compiler: revert ce2fdb7; close #6388
The commit was to stop warnings from Visual C but unexpectedly caused
compilation errors on some configuration.
2024-10-22 14:46:12 +09:00
Yukihiro "Matz" Matsumoto 51fd065722 mruby-compiler (parser_yylex): skip sign if bigint starts with +
To reserve memory (1 byte) and avoid error (fixed by 11cff8f).
2024-10-22 14:45:48 +09:00
Yukihiro "Matz" Matsumoto 11cff8fa7d mruby-bigint (mpz_init_set_str): should skip + in the string
When the string starts with `+` it should not cause error silently. It
might cause serious error afterwards.
2024-10-22 14:44:51 +09:00
Yukihiro "Matz" Matsumoto f2908031c4 Merge pull request #6387 from dearblue/gc-unregister.1 2024-10-21 10:56:49 +09:00
Yukihiro "Matz" Matsumoto f6fbfdfcf0 Merge pull request #6386 from dearblue/gc-unregister 2024-10-21 10:55:38 +09:00
Yukihiro "Matz" Matsumoto df0fc6f3a8 Merge pull request #6385 from dearblue/gc-register.1 2024-10-21 10:49:37 +09:00
Yukihiro "Matz" Matsumoto c317659b8f Merge pull request #6382 from dearblue/gc-register 2024-10-21 10:48:46 +09:00
Yukihiro "Matz" Matsumoto 1f5ba7e01d vm.c (OP_STRCAT): mrb_str_concat may call VM recursively
And recursive calls may reallocate call-info stack.
2024-10-20 19:46:23 +09:00
Yukihiro "Matz" Matsumoto d8e6987e4c Merge pull request #6358 from jbampton/add-latest-ubuntu-to-build 2024-10-19 02:17:59 -04:00
Yukihiro "Matz" Matsumoto 56fc329633 Merge pull request #6383 from jbampton/remove-macos-12 2024-10-19 00:28:25 -04:00
Yukihiro "Matz" Matsumoto f3257c448b mruby-bigint (mrb_bint_powm): should call mpz_clear() on exceptions 2024-10-19 13:09:03 +09:00
Yukihiro "Matz" Matsumoto e4d2f343fe mruby-bigint (mrb_bint_neg): move the function to group bit operations 2024-10-19 12:47:06 +09:00
Yukihiro "Matz" Matsumoto ee13b9e67b mruby-bigint: fix mrb_int optimization bugs for and, or, xor
If the operand is a small integer, those functions tried to reduce
bigint allocations, but we had some bugs in them. We removed those
imperfect optimization altogether.
2024-10-19 12:45:04 +09:00
dearblue 2ec2437d23 Small improvements for mrb_gc_unregister()
`ARY_PTR()` and `ARY_LEN()` avoid using them in a loop if the array is not changed, since they involve branching.
2024-10-19 11:10:10 +09:00
dearblue 1dcc2cac03 Avoid calling mrb_gv_set() from mrb_gc_unregister()
Should simply be ignored for the possibility of being called from `RData::dfree`.
2024-10-19 11:08:32 +09:00
dearblue b28d53bda9 Small improvements for mrb_gc_register()
The `mrb_nil_p()` used in conditional expressions is semantically included in `!mrb_array_p()`.
2024-10-19 10:59:21 +09:00
Yukihiro "Matz" Matsumoto 2430eaba13 mruby-bigint (mrb_bint_powm): fixed memory leak 2024-10-19 07:32:06 +09:00
Yukihiro "Matz" Matsumoto 001d5fcc3f mruby-bigint (mpz_get_str): get b2 by table lookup
The `b2` is the power of `base` no bigger than DIG_BASE.
2024-10-19 07:32:05 +09:00
Yukihiro "Matz" Matsumoto 4aa87acfc9 mruby-bigint (mpz_set_uint64): adjust reallocation size for uint64
The uint64_t value may fit in `mp_limb*n` where n is 1..4.
2024-10-19 07:32:05 +09:00
John Bampton 86e969a406 Remove macOS 12 from the build
The macOS 12 runner image will be removed by December 3rd, 2024.
2024-10-19 00:18:19 +10:00
dearblue 13512aba91 Make array objects invisible in mrb_gc_register()
Once the class is set, objects can be referenced and manipulated from the Ruby side by using `ObjectSpace.each_object`.
Also, currently `mrb_gc_unregister()` assumes that the element is a non-immediate object.
However, `mrb_gc_unregister()` does not read or write to the address, so there was no problem.
2024-10-18 22:29:23 +09:00
Yukihiro "Matz" Matsumoto c3be2568ea Merge pull request #6005 from jbampton/build-and-test-on-macos-13 2024-10-17 23:28:03 -04:00
Yukihiro "Matz" Matsumoto 5e6d382782 mruby-bigint (mpz_set_uint64): fixed a bug in for loop
Found double increments in a loop. Since no one called mpz_set_int64()
in the real code, we could not find this bug for long time.
2024-10-18 12:27:02 +09:00
Yukihiro "Matz" Matsumoto fe42f1d047 mruby-bigint (mpz_set_int): simplify using early return 2024-10-18 12:27:02 +09:00
Yukihiro "Matz" Matsumoto a5c0b2114a mruby-bigint (mrb_bint_2comp): need to initialize mpz_t 2024-10-18 12:27:02 +09:00