Commit Graph

16237 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto ecd42ab3e9 Merge pull request #6360 from jbampton/add-actionslint-to-pre-commit 2024-09-22 20:21:44 +09:00
Yukihiro "Matz" Matsumoto 1b875a925c Merge pull request #6364 from jbampton/fix-spelling 2024-09-22 20:19:06 +09:00
John Bampton b974b944af docs: fix spelling 2024-09-22 12:16:23 +10:00
John Bampton 6d749e92ed Add pre-commit hook actionlint
Validate GitHub Actions with pre-commit.

Remove the Super-Linter GitHub Actions check.

It is more useful to run "actionlint" with pre-commit
since the hooks run on our local machines on git commit.

We also run pre-commit on GitHub.

Whereas the Super-Linter tests only run on GitHub.

https://github.com/rhysd/actionlint/blob/main/docs/usage.md#pre-commit
2024-09-22 08:51:42 +10:00
Yukihiro "Matz" Matsumoto bd668e4c9d readfloat.c: new implementation of mrb_read_float(); ref #6187
The new version gives more accurate values for decimal number
representation that are not divisible in binary representations, for
example `0.3`.

The function uses `long double` for precision. Please report if `long
double` causes problems on any platform (especially microcontrollers).
Ref #6182
2024-09-21 02:47:42 +09:00
Yukihiro "Matz" Matsumoto c162f8f709 Merge pull request #6356 from dearblue/get-args-splat 2024-09-21 00:03:38 +09:00
dearblue cf23861166 Making splat argument objects invisible from Ruby side
The `mrb_get_argv()` function and the `*` specifier of `mrb_get_args()` get the address of the argument.
At this time, if it is passed in the form of a splat argument, it will be an address to an element of an array object.

After getting the pointer to the array object, the caller may call `mrb_vm_exec()` directly or indirectly.
At this time, a splat argument with the class set can be retrieved as an array object by searching with `ObjectSpace.each_object`.
If changes are made as array objects, addresses on the heap as arrays may become invalid, or objects in the array may be recycled by the GC.
When the caller references the changed address in a subsequent operation, use-after-free is established.

This patch assigns `NULL` as the class of the array object so that it cannot be detected by `ObjectSpace.each_object` from the Ruby side.
2024-09-19 23:13:18 +09:00
Yukihiro "Matz" Matsumoto f6caf0d788 mruby-bigint (mrb_init_set_str): reduce mpz_t allocations 2024-09-19 20:52:11 +09:00
Yukihiro "Matz" Matsumoto e3ff54fda3 vm.c (mrb_vm_exec): unify declaration and initialization of variables 2024-09-18 22:32:35 +09:00
Yukihiro "Matz" Matsumoto d1d010a03a array.c (mrb_ary_delete): array index should be mrb_int 2024-09-17 12:07:39 +09:00
Yukihiro "Matz" Matsumoto ba8ee7b895 mruby-socket (inet_pton): need to initialize loop variable 2024-09-17 12:05:46 +09:00
Yukihiro "Matz" Matsumoto 4b500eb971 Merge pull request #6340 from dearblue/array-cmp 2024-09-17 11:29:41 +09:00
Yukihiro "Matz" Matsumoto b8a6752570 Merge pull request #6354 from dabroz/dabroz-patch-1 2024-09-17 11:00:49 +09:00
Tomasz Pędraszewski 78ee1529d6 Update AUTHORS 2024-09-17 00:01:02 +02:00
Yukihiro "Matz" Matsumoto de6955b1b0 vm.c (mrb_vm_run): merge declaration and initialization 2024-09-16 17:50:13 +09:00
Yukihiro "Matz" Matsumoto fddc7650ca numeric.c (int_ceil): should rename mrb_bint_add_d to mrb_bint_add_n 2024-09-15 04:00:52 +09:00
Yukihiro "Matz" Matsumoto afefb5261b mruby-rational (rat_sub_b): avoid normalization of big integers 2024-09-15 03:04:32 +09:00
Yukihiro "Matz" Matsumoto bdbf8536a7 mruby-bigint: rename add_d and sub_d to add_n and sub_n respectively
`_n` suffix represents `no_normalize`.
2024-09-15 03:02:41 +09:00
Yukihiro "Matz" Matsumoto 50225acec4 mruby-rational (rat_mul_b): should not normalize multiplication results 2024-09-15 02:50:57 +09:00
Yukihiro "Matz" Matsumoto 3ce96e5c4d Merge pull request #6353 from dearblue/array-delete 2024-09-14 06:11:54 +09:00
dearblue 0955539cf9 Fix use-after-free in mrb_ary_delete()
`mrb_equal()` may call `obj.==` method internally.
Therefore, using an unupdated pointer and length after `mrb_equal()` could result in a read/write to an invalid address.

Fresh properties must always be obtained regardless of the result of `mrb_equal()`.
Also, `ary_modify()` must be called each time before writing.

ref. #6339
2024-09-13 21:44:56 +09:00
Yukihiro "Matz" Matsumoto 6e44c0bc91 vm.c (argnum_error): merge declaration and initialization 2024-09-13 07:27:17 +09:00
Yukihiro "Matz" Matsumoto 704ad87150 Merge pull request #6338 from dearblue/proc-align 2024-09-12 06:43:42 +09:00
Yukihiro "Matz" Matsumoto ee9b1381ec Merge pull request #6347 from leviongit/fixes/yield-kw-codegen
codegen.c,parse.y: remove flattening of `yield` arguments; fix #6346
2024-09-12 06:39:27 +09:00
Yukihiro "Matz" Matsumoto 413b005801 Merge pull request #6349 from dearblue/dir-test 2024-09-11 07:12:31 +09:00
Yukihiro "Matz" Matsumoto a38dd0c988 Merge pull request #6350 from dearblue/io-filepath 2024-09-11 07:10:45 +09:00
Yukihiro "Matz" Matsumoto 9aee23b056 Merge pull request #6351 from dearblue/io-arena 2024-09-11 07:09:11 +09:00
Yukihiro "Matz" Matsumoto 06db87e758 Merge pull request #6348 from dearblue/warnings 2024-09-10 22:11:14 +09:00
dearblue 9cb42438e1 Remove unnecessary mrb_gc_arena_restore()
When a function defined as a method returns, there is no need to call `mrb_gc_arena_restore()` immediately before it.
2024-09-10 21:45:44 +09:00
dearblue 33cf729a39 Fixed character encoding conversion function mismatch 2024-09-10 21:34:05 +09:00
dearblue 3aa9a5ee68 Perform GC before deleting directories
In some environments, the test will fail because the directory in use cannot be deleted.
This problem was encountered when building 32-bit binary with mingw32 on FreeBSD and running on wine.
2024-09-10 21:17:10 +09:00
dearblue 8b495cdfda Cancel the warning disablement
Suppress warnings for 0-length sequences is not required.

By commit f1a02dff58, it was introduced.
By commit 24939723d7, pseudo-variable length arrays are now used and the warning suppression is no longer needed.
By commit e8841fbf58, moved the intervening code.
2024-09-10 21:07:43 +09:00
Yukihiro "Matz" Matsumoto da4cfbf89c mruby-array-ext: add a new method Array#fetch_values 2024-09-10 10:22:34 +09:00
leviongit 87801ed5f1 codegen.c,parse.y: remove flattening of yield arguments; fix #6346
this commit changes the parse tree of the `yield` node, allowing for
proper keyword argument generation
2024-09-09 10:06:31 +02:00
Yukihiro "Matz" Matsumoto 0972c84773 array.c (mrb_ary_delete): protect return value; fix #6339
The C local variable is not protected from GC, so we use the function
mrb_gc_protect() to keep the value. We also keep the arena position by
mrb_gc_arena_save(), then restoring the position for every new return
value, to minimize arena size.

Small cosmetic changes (pre-increment to post-increment) are also made
in this commit.
2024-09-09 14:57:32 +09:00
Yukihiro "Matz" Matsumoto 1c4514964e AUTHORS: update entries [ci skip] 2024-09-09 09:55:30 +09:00
Yukihiro "Matz" Matsumoto 2d871fb1ef vm.c (catch_handler_find): merge declaration and initialization 2024-09-09 07:10:50 +09:00
Yukihiro "Matz" Matsumoto a3aff8f437 vm.c (mrb_yield_cont): merge declaration and initialization 2024-09-07 08:36:02 +09:00
Yukihiro "Matz" Matsumoto 1f9fa06119 array.c: no need to assert if blk is a Proc; ref #6344
Since `blk` always comes from `mrb_get_args`, it should always be either
`nil` or a Proc.
2024-09-05 15:26:09 +09:00
Yukihiro "Matz" Matsumoto 3ca3849f54 Merge pull request #6344 from leviongit/array/yield 2024-09-05 15:23:01 +09:00
leviongit 020cfa9283 prefer using mrb_yield to call block arguments 2024-09-04 20:44:51 +02:00
Yukihiro "Matz" Matsumoto 4671459e73 Merge pull request #6343 from mruby/dependabot/bundler/yard-0.9.37 2024-09-05 00:10:42 +09:00
dependabot[bot] c3615be2ac build(deps): bump yard from 0.9.36 to 0.9.37
Bumps [yard](https://github.com/lsegal/yard) from 0.9.36 to 0.9.37.
- [Release notes](https://github.com/lsegal/yard/releases)
- [Changelog](https://github.com/lsegal/yard/blob/main/CHANGELOG.md)
- [Commits](https://github.com/lsegal/yard/compare/v0.9.36...v0.9.37)

---
updated-dependencies:
- dependency-name: yard
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-04 14:52:41 +00:00
Yukihiro "Matz" Matsumoto 649162624f Merge pull request #6341 from dearblue/restore-arena 2024-09-04 09:39:41 +09:00
dearblue e476d9a344 Need to restore the GC arena after some function calls
When calling `mrb_equal()` or `mrb_funcall()` family functions, the GC arena should be restored if the loop is repeated by a non-immediate return value.

In my opinion, restoring the GC arena is unnecessary when a non-immediate (true) value causes the function to return (e.g. the `mrb_ary_index_m()` function).

The patch does not take into account the case of recursive calls and may be incomplete.
2024-09-03 21:29:06 +09:00
dearblue 29496c9931 Fix use-after-free for Array#<=>
The `mrb_ary_cmp()` function calls `mrb_cmp()` for comparison, but `mrb_cmp()` may call the `obj.<=>` method internally.
If a user-defined `<=>` method is called and the array object under comparison is expanded or reduced, a reference to an invalid address may subsequently be made.
2024-09-03 21:25:31 +09:00
Yukihiro "Matz" Matsumoto 1d12097bae mruby-io (mrb_file__gethome): allow avoiding getpwnam(3); ref #5358
You have to define `MRB_IO_NO_PWNAM` to skip calling getpwname(3).
2024-09-03 15:27:29 +09:00
Yukihiro "Matz" Matsumoto 96cf9ba230 vm.c (mrb_yield_with_class): merge declaration and initialization 2024-09-03 11:58:20 +09:00
Yukihiro "Matz" Matsumoto 4062069679 gc.c (gc_arena_keep): revert 2 commits regarding arena allocation; #6329
We assumed there's no need for gc_arena_keep() when MRB_GC_FIXED_ARENA
is set.  But it turned out that gc_protect() still can cause use-after-free
with fixed arena.

Revert "gc.c (gc_protect): should not call gc_arena_keep twice from allocation"

This reverts commit 28ece4ed8b.

Revert "gc.c (gc_arena_keep): reorganized for MRB_GC_FIXED_ARENA; ref #6329"

This reverts commit 33dd623a02.
2024-09-02 23:00:09 +09:00
Yukihiro "Matz" Matsumoto 6c4dbe8584 vm.c (eval_under): unify declaration and initialization of variables 2024-09-02 11:52:32 +09:00