Yukihiro "Matz" Matsumoto
6de3009606
Merge pull request #6328 from dearblue/env-obj_free
2024-08-28 16:40:04 +09:00
Yukihiro "Matz" Matsumoto
4a71d4604e
mruby-rational: add typecast to check if a value is fit in mrb_int
2024-08-27 22:48:40 +09:00
Yukihiro "Matz" Matsumoto
540d976f7f
array.c (sort_cmp): mrb_cmp() may return -2 for errors
2024-08-27 22:36:24 +09:00
Yukihiro "Matz" Matsumoto
28ece4ed8b
gc.c (gc_protect): should not call gc_arena_keep twice from allocation
2024-08-27 11:03:14 +09:00
Yukihiro "Matz" Matsumoto
ef5ae1c629
Merge pull request #6333 from dearblue/heap_p
2024-08-26 05:49:49 +09:00
Yukihiro "Matz" Matsumoto
33dd623a02
gc.c (gc_arena_keep): reorganized for MRB_GC_FIXED_ARENA; ref #6329
2024-08-26 05:47:28 +09:00
Yukihiro "Matz" Matsumoto
1a322449aa
Merge pull request #6331 from dearblue/test-gcarena
2024-08-26 05:47:48 +09:00
Yukihiro "Matz" Matsumoto
b9c93673f9
Merge pull request #6329 from dearblue/mrb_obj_alloc
2024-08-26 05:40:12 +09:00
Yukihiro "Matz" Matsumoto
325c918464
class.c: use mrb_unboxed_type where obj is not immediate for sure
2024-08-26 05:33:19 +09:00
dearblue
98fdfe1037
Reduce the number of branch instructions in the heap_p()
...
As far as `gcc -S` for several CPU architectures has confirmed, it reduces the number of branch instructions by one.
2024-08-25 20:35:41 +09:00
dearblue
79d7ac5f7e
Restore the GC arena with tests.
...
This was the unintentional catalyst for finding the problem in #6329 , but it is preferable to add a test if necessary.
2024-08-25 11:08:40 +09:00
dearblue
1c5839fb01
Fix use-after-free in mrb_obj_alloc()
...
When GC occurs during the expansion of the GC arena by `gc_protect()` in `mrb_obj_alloc()`, the object page just allocated by `add_heap()` is released.
Therefore, as soon as control returns from `gc_protect()`, there is a possibility of illegal writing or reading to the address just released.
This issue was discovered during the investigation of #6326 .
2024-08-25 10:55:15 +09:00
Yukihiro "Matz" Matsumoto
a2db222422
Merge pull request #6330 from dearblue/mrb_env_unshare
2024-08-24 21:47:44 +09:00
dearblue
13571402d2
Add a precondition to call mrb_env_unshare().
...
The following assertions can be added to omit the `if` block
- env object must be non-null
- env object must be in a shared state with the stack
The current caller is believed to satisfy the condition.
2024-08-24 17:30:54 +09:00
dearblue
22b1ac9070
Fix use-after-free in obj_free() for env objects
...
A reference to an invalid address might occur in `is_dead()` of `obj_free()` called from `incremental_sweep_phase()`.
This would happen if the heap page was freed ahead of time in the same `incremental_sweep_phase()`.
fixed #6326
2024-08-24 16:46:27 +09:00
Yukihiro "Matz" Matsumoto
204b81c563
mruby-bin-mirb: fix the issue on macOS; #6327
2024-08-24 07:13:45 +09:00
Yukihiro "Matz" Matsumoto
7ba95e2f5e
Merge pull request #6327 from juchem/master
2024-08-23 22:33:44 +09:00
Yukihiro "Matz" Matsumoto
f35000f2a9
array.c (sort_cmp): comparing objects may be freed by GC; #6326
...
If comparing function (block or `<=>`) modifies the sorting array and GC
happens after the modification, objects passed to comparison may be
freed by GC.
2024-08-23 22:29:45 +09:00
Marcelo Juchem
a6eb3e5c27
fix ncurses linking issues
...
The build configuration for `mruby` assumes only the `ncurses` library
needs to be linked because `tinfo` is implicitly pulled in.
In environments where ncurses is available only as a static library,
`tinfo` needs to be linked explicitly (needed for functions like
`tputs`.
This patch fixes that by linking `tinfo` if available.
It also fixes the build for environments where only the `ncursesw`
version of the library (including wide character support) is present,
while still giving preference to the `ncurses` version (without wide
character support).
2024-08-22 14:11:48 -05:00
Yukihiro "Matz" Matsumoto
58c70834d9
array.c (srot_cmp): need modify check after mrb_cmp as well; #6326
...
mrb_cmp() may also modify the sorting array internally.
2024-08-22 07:49:16 +09:00
Yukihiro "Matz" Matsumoto
4ea6d74d83
mruby-rational: introduce the constants ONE and ZERO
2024-08-21 18:38:51 +09:00
Yukihiro "Matz" Matsumoto
752ebe6b7f
array.c (mrb_ary_sort_bang): check if array is modified in blocks
...
This address at least part of #6326 . CRuby copied the array internally,
but mruby avoid copying to reserve memory.
2024-08-21 18:31:46 +09:00
Yukihiro "Matz" Matsumoto
4b9f567821
vm.c (exec_irep): unify declaration and initialization
2024-08-20 12:49:45 +09:00
Yukihiro "Matz" Matsumoto
98440e095f
vm.c (mrb_ci_nregs): unify declaration and initialization
2024-08-20 10:39:12 +09:00
Yukihiro "Matz" Matsumoto
166262243a
benchmark/bm_so_mandelbrot.rb: add new benchmark
2024-08-18 23:11:29 +09:00
Yukihiro "Matz" Matsumoto
39b9a1a06a
mruby-rational (rational_new): fix compilation condition
2024-08-17 16:29:51 +09:00
Yukihiro "Matz" Matsumoto
44908e5cba
mruby-rational: support bigint numerators & denominators
2024-08-16 15:12:03 +09:00
Yukihiro "Matz" Matsumoto
92f476d8fa
mruby-bigint (mpz_set): trim destination mpz_t
2024-08-16 07:32:05 +09:00
Yukihiro "Matz" Matsumoto
479259b4e1
Merge pull request #6324 from dearblue/localjump_error
2024-08-16 06:22:32 +09:00
Yukihiro "Matz" Matsumoto
b202d00219
Merge pull request #6325 from mruby/dependabot/github_actions/super-linter/super-linter-7.0.0
2024-08-16 06:19:16 +09:00
dependabot[bot]
f3b24009e6
build(deps): bump super-linter/super-linter from 6.9.0 to 7.0.0
...
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter ) from 6.9.0 to 7.0.0.
- [Release notes](https://github.com/super-linter/super-linter/releases )
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md )
- [Commits](https://github.com/super-linter/super-linter/compare/v6.9.0...v7.0.0 )
---
updated-dependencies:
- dependency-name: super-linter/super-linter
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com >
2024-08-15 14:34:20 +00:00
Yukihiro "Matz" Matsumoto
a4225709ef
Merge pull request #6323 from mruby/dependabot/github_actions/super-linter/super-linter-6.9.0
2024-08-15 12:15:17 +09:00
dearblue
9d0617f27b
Remove localjump_error()
...
Suppress heap allocation for strings.
2024-08-15 10:27:53 +09:00
Yukihiro "Matz" Matsumoto
dfe2dbcde6
class.c (init_copy): need to copy float numbers in some cases
...
If `MRB_BOXING_WORD` and `MRB_WORDBOXING_NO_FLOAT_TRANCATE` is defined,
float numbers are packed in the heap object. We need to copy them
explicitly.
2024-08-15 09:57:56 +09:00
dependabot[bot]
eb6d7afd7e
build(deps): bump super-linter/super-linter from 6.8.0 to 6.9.0
...
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter ) from 6.8.0 to 6.9.0.
- [Release notes](https://github.com/super-linter/super-linter/releases )
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md )
- [Commits](https://github.com/super-linter/super-linter/compare/v6.8.0...v6.9.0 )
---
updated-dependencies:
- dependency-name: super-linter/super-linter
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com >
2024-08-14 14:56:30 +00:00
Yukihiro "Matz" Matsumoto
e9c4486e27
mruby-bigint: add fast path to mrb_bint_mul() & mrb_bint_div()
2024-08-14 22:36:47 +09:00
Yukihiro "Matz" Matsumoto
16f5000794
Merge pull request #6320 from dearblue/OP_BREAK
2024-08-14 18:02:34 +09:00
Yukihiro "Matz" Matsumoto
6e5a493ff3
mruby-bigint (mrb_bint_new_float): add fast path for FIXABLE_FLOAT
2024-08-14 16:11:27 +09:00
Yukihiro "Matz" Matsumoto
92302df49d
Merge pull request #6322 from hoshiumiarata/fix_mrb_ro_data_p
2024-08-13 17:50:35 +09:00
Hoshiumi Arata
da54da1923
Fix mrb_ro_data_p on Intel Mac
2024-08-13 17:27:08 +09:00
Yukihiro "Matz" Matsumoto
1e503f902d
Merge pull request #6321 from dearblue/lib-warnings
2024-08-13 11:48:21 +09:00
Yukihiro "Matz" Matsumoto
c853dc4090
vm.c (funcall): move va_list declaration right before va_start()
2024-08-12 22:57:05 +09:00
dearblue
79f4a67268
Avoid warnings in lib/**/*.rb
...
```console
% find -s lib -type f -name '*.rb' -exec ruby -cw {} \;
lib/mruby/build/command.rb:320: warning: `+' after local variable or literal is interpreted as binary operator
lib/mruby/build/command.rb:320: warning: even though it seems like unary operator
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
lib/mruby/gem.rb:469: warning: `&' interpreted as argument prefix
Syntax OK
Syntax OK
Syntax OK
Syntax OK
```
2024-08-12 21:06:31 +09:00
dearblue
682583a609
Shrinking the code in OP_BREAK and OP_RETURN_BLK
...
- Can refer directly to `proc->e.env` after `MRB_PROC_ENV_P()`.
- Can omit `MRB_ENV_ONSTACK_P()` since `mrb->c` is never NULL and can be directly compared to `env->cxt`.
- Can avoid `goto` by putting the code block that raises the `LocalJumpError` at the end.
2024-08-12 20:54:55 +09:00
Yukihiro "Matz" Matsumoto
22eb7e87af
vm.c (uvenv): move declaration to initialization
2024-08-11 23:45:40 +09:00
Yukihiro "Matz" Matsumoto
7ca60a0964
vm.c (stack_extend_alloc): move variable declaration to initialization
2024-08-10 21:57:51 +09:00
Yukihiro "Matz" Matsumoto
56a82009aa
Revert "The lex_state after literals should be EXPR_ENDARG."; fix #6298
...
This reverts commit e98823f189 .
2024-08-10 19:17:49 +09:00
Yukihiro "Matz" Matsumoto
a267dfd76b
vm.c (OP_CLASS,OP_MODULE): combine declarations with initializers
2024-08-08 06:11:52 +09:00
Yukihiro "Matz" Matsumoto
22ec76f46c
vm.c (OP_RANGE_INC): remove unnecessary local variable
2024-08-08 06:10:35 +09:00
Yukihiro "Matz" Matsumoto
320c757186
Merge pull request #6318 from dearblue/shrink-vm-vars
...
Shrink variables in `mrb_vm_exec()`
2024-08-06 12:21:36 +09:00