summaryrefslogtreecommitdiffhomepage
path: root/src
AgeCommit message (Collapse)Author
2021-03-29Revert "Fix `SIGSEGV` with mruby-method + mruby-catch"revert-5391-throwYukihiro "Matz" Matsumoto
2021-03-29Merge pull request #5391 from dearblue/throwYukihiro "Matz" Matsumoto
Fix `SIGSEGV` with mruby-method + mruby-catch
2021-03-28numeric.c: function renaming.Yukihiro "Matz" Matsumoto
- `mrb_num_div_int(mrb,x,y)` -> `mrb_div_int(mrb,x,y)` - `mrb_num_div_flo(mrb,x,y)` -> `mrb_div_flo(x,y)` They are internal function not supposed to be used outside of the core.
2021-03-27Fix `SIGSEGV` with mruby-method + mruby-catchdearblue
Previously, the following code would cause a `SIGSEGV`. ```ruby mm = method(:throw) define_method(:throw, ->(*args) { mm.call(*args) }) catch { |tag| throw tag } ``` I think the reason is in the `mrb_yield_with_class()` function: - Even if a C function is called, `CI_ACC_SKIP` is used - `cipop()` is not done if globally jumping from a C function
2021-03-19complex.c: overhaul complex operators.Yukihiro "Matz" Matsumoto
- define `MRB_TT_COMPLEX` - change object structure (`struct RComplex`) - add memory management for `MRB_TT_COMPLEX` - avoid operator overloading as much as possible - as a result, performance improved a log - should work with and without `Rational` defined
2021-03-19rational.c: overhaul rational operators.Yukihiro "Matz" Matsumoto
- define `MRB_TT_RATIONAL` - change object structure (`struct RRational`) - add memory management for `MRB_TT_RATIONAL` - avoid operator overloading as much as possible - implement division overloading in C - as a result, performance improved a lot
2021-03-19numeric.c: avoid integer overflow; close #5384Yukihiro "Matz" Matsumoto
Since `mruby` does not have `Bignum`, `Float#divmod` could overflow, so it will return `Float` values when the divided value does not fit in `mrb_int`. This behavior will be changed when `Bignum` is introduced to `mruby` in the future.
2021-03-19`Float#divmod` with zero should cause `ZeroDivisionError`; #5384Yukihiro "Matz" Matsumoto
2021-03-18`Float::NAN/0` should be `Float::NAN`; ref a0b3378b3KOBAYASHI Shuji
#### Before this patch: ```console $ bin/mruby -e 'p(Float::NAN/0)' Infinity ``` #### After this patch (same as Ruby): ```console $ bin/mruby -e 'p(Float::NAN/0)' NaN ```
2021-03-18numeric.c: float zero division should be infinity with sign kept; fix #5382Yukihiro "Matz" Matsumoto
2021-03-17hash.c: `Hash#shift` to return `nil` when a hash is empty.Yukihiro "Matz" Matsumoto
It used to be return the default value if available, but it should ignore the default value for behavior consistency. CRuby will adopt this behavior too in the future. [ruby-bugs:16908]
2021-03-17range.c: fixed a begin-less ranges issue.Yukihiro "Matz" Matsumoto
2021-03-12codegen.c: fixed a typo.Yukihiro "Matz" Matsumoto
2021-03-12codegen.c: no integer overflow error in `codegen`; close #5376Yukihiro "Matz" Matsumoto
Add new pool value type `IREP_TT_BIGINT` and generate integer overflow error in the VM. In the future, `mruby` will support `Bignum` for integers bigger than `mrb_int` (probably using `mpz`).
2021-03-09Merge pull request #5375 from artichoke/mrb_cmp-presym-op-maroYukihiro "Matz" Matsumoto
bug(presym): Fix mrb_cmp declaration of <=> symbol for funcall
2021-03-07bug(presym): Fix mrb_cmp declaration of <=> symbol for funcallRyan Lopopolo
2021-03-08ISO C99 doesn't support unnamed unions; fix #5354Yukihiro "Matz" Matsumoto
2021-03-05Fix load 64-bit integer from mrb format; fix #5369KOBAYASHI Shuji
2021-03-01dump.c: remove operator_table if `MRB_NO_STDIO` is defined.Yukihiro "Matz" Matsumoto
2021-02-28Remove periods from error messages according to the convention.Yukihiro "Matz" Matsumoto
2021-02-27state.c: remove `stdint.h` inclusion.Yukihiro "Matz" Matsumoto
Fixes C++03 compilation.
2021-02-26state.c: check irep reference count overflow.Yukihiro "Matz" Matsumoto
2021-02-22Added other methods for `Binding`dearblue
- Added to `mruby-binding-core` - `Binding#local_variable_defined?` - `Binding#local_variable_get` - `Binding#local_variable_set` - `Binding#local_variables` - `Binding#receiver` - `Binding#source_location` - `Binding#inspect` - Added to `mruby-proc-binding` - `Proc#binding` The reason for separating `Proc#binding` is that core-mrbgems has a method that returns a closure object to minimize possible problems with being able to manipulate internal variables. By separating it as different mrbgem, each user can judge this problem and incorporate it arbitrarily.
2021-02-22Adjustment of the current HEAD and bindings, and separationdearblue
Make changes to make `Binding` work. At the same time, it separates `Binding#eval`, which depends on `mruby-eval`, from `mruby-binding-core`.
2021-02-22print.c: fix a compilation errors with `MRB_NO_STDIO`; fix #5361Yukihiro "Matz" Matsumoto
2021-02-19Check `MRB_TT_*` before object allocation; ref #5352Yukihiro "Matz" Matsumoto
2021-02-18Merge pull request #5352 from ↵Yukihiro "Matz" Matsumoto
shuujii/fix-type-tag-that-set-to-NilClass-and-FalseClass Fix type tag that set to `NilClass` and `FalseClass`
2021-02-17Merge pull request #5347 from ↵Yukihiro "Matz" Matsumoto
shuujii/add--s-option-to-mrbc-for-make-variable-static Add `-s` option to `mrbc` for make variable static
2021-02-16Update URL explaining alignment issue; close #5344Yukihiro "Matz" Matsumoto
2021-02-14Fix type tag that set to `NilClass` and `FalseClass`KOBAYASHI Shuji
2021-02-14Place optable in ROMdearblue
2021-02-14Add `-s` option to `mrbc` for make variable staticKOBAYASHI Shuji
2021-02-13chore: fix missing HTTPS on linksJohn Bampton
2021-02-12Avoid possibility of reading uninitialized areas in `h_check_modified()`KOBAYASHI Shuji
In `h_check_modified()`, in the case of `MRB_NO_BOXING`, `ht_ea()` or `ht_ea_capa()` for AR may read uninitialized area. Therefore, do not use those macros for AR in `MRB_NO_BOXING` (but in the case of `MRB_64BIT`, `ht_ea_capa()` is the same as `ar_ea_capa()`, so use it). fix #5332
2021-02-12src/print.c: stop warning with `MRB_NO_STDIO`.Yukihiro "Matz" Matsumoto
2021-02-10Fix heap-buffer-overflow for small `Hash` (HT) in `Hash#rehash`KOBAYASHI Shuji
### Example ##### example.rb ```ruby h = {} (1..17).each{h[_1] = _1} (1..16).each{h.delete(_1)} h.rehash ``` ##### ASAN report ```console $ bin/mruby example.rb ==52587==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000006998 at pc 0x55a29cddf96b bp 0x7fff7b1b1720 sp 0x7fff7b1b1710 READ of size 4 at 0x602000006998 thread T0 #0 0x55a29cddf96a in ib_it_next /mruby/src/hash.c:639 #1 0x55a29cde2ca2 in ht_rehash /mruby/src/hash.c:900 #2 0x55a29cde379f in h_rehash /mruby/src/hash.c:996 #3 0x55a29cde7f3d in mrb_hash_rehash /mruby/src/hash.c:1735 #4 0x55a29ce77b62 in mrb_vm_exec /mruby/src/vm.c:1451 #5 0x55a29ce5fa88 in mrb_vm_run /mruby/src/vm.c:981 #6 0x55a29ceb87e1 in mrb_top_run /mruby/src/vm.c:2874 #7 0x55a29cf36bdf in mrb_load_exec mrbgems/mruby-compiler/core/parse.y:6805 #8 0x55a29cf36f25 in mrb_load_detect_file_cxt mrbgems/mruby-compiler/core/parse.y:6848 #9 0x55a29cdba0a2 in main /mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:347 #10 0x7f24ef43b0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2) #11 0x55a29cdb4a6d in _start (/mruby/bin/mruby+0x2a3a6d) 0x602000006998 is located 0 bytes to the right of 8-byte region [0x602000006990,0x602000006998) allocated by thread T0 here: #0 0x7f24f01cfffe in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe) #1 0x55a29ceb9440 in mrb_default_allocf /mruby/src/state.c:68 #2 0x55a29cdba747 in mrb_realloc_simple /mruby/src/gc.c:228 #3 0x55a29cdba928 in mrb_realloc /mruby/src/gc.c:242 #4 0x55a29cde12e5 in ht_init /mruby/src/hash.c:749 #5 0x55a29cde2b8e in ht_rehash /mruby/src/hash.c:897 #6 0x55a29cde379f in h_rehash /mruby/src/hash.c:996 #7 0x55a29cde7f3d in mrb_hash_rehash /mruby/src/hash.c:1735 #8 0x55a29ce77b62 in mrb_vm_exec /mruby/src/vm.c:1451 #9 0x55a29ce5fa88 in mrb_vm_run /mruby/src/vm.c:981 #10 0x55a29ceb87e1 in mrb_top_run /mruby/src/vm.c:2874 #11 0x55a29cf36bdf in mrb_load_exec mrbgems/mruby-compiler/core/parse.y:6805 #12 0x55a29cf36f25 in mrb_load_detect_file_cxt mrbgems/mruby-compiler/core/parse.y:6848 #13 0x55a29cdba0a2 in main /mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:347 #14 0x7f24ef43b0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2) ```
2021-02-05`instance_eval` for classes and modules should behave as `class_eval`.Yukihiro "Matz" Matsumoto
2021-02-03Move `MRB_TRY` part of `mrb_close` to `src/error.c`; ref 6cc52b3Yukihiro "Matz" Matsumoto
We don't want to increase number of files that should be compiled by C++ compiler when `enable_cxx_exception` is turned on.
2021-02-02Ignore errors from `atexit` finalizers.Yukihiro "Matz" Matsumoto
2021-02-01Allow more than 256 child `irep`; fix #5310Yukihiro "Matz" Matsumoto
We have introduced following new instructions. * `OP_LAMBDA16` * `OP_BLOCK16` * `OP_METHOD16` * `OP_EXEC16` Each instruction uses 16 bits operand for `reps` index. Since new instructions are added, `mruby/c` VM should be updated. Due to new instructions, dump format compatibility is lost, we have increased `RITE_BINARY_MAJOR_VER`. In addition, we have decreased the size of `refcnt` in `mrb_irep` from `uint32_t` to `uint16_t`, which is reasonably big enough.
2021-02-01Copy `iv` table with `#prepend`; fix #5309Yukihiro "Matz" Matsumoto
In addition, stop eager allocation of `mt` table.
2021-02-01Merge pull request #5314 from dearblue/presym_initYukihiro "Matz" Matsumoto
Introduced `MRB_PRESYM_INIT_SYMBOLS()`
2021-02-01Merge pull request #5313 from dearblue/diet-5272Yukihiro "Matz" Matsumoto
Remove unnecessary `ci0` variables; ref #5272
2021-01-31Introduced `MRB_PRESYM_INIT_SYMBOLS()`dearblue
The `init_SYMBOLS()` function implicitly defined in `MRB_PRESYM_DEFINE_VAR_AND_INITER()` requires some familiarity when trying to find it from the caller. By introducing `MRB_PRESYM_INIT_SYMBOLS()`, it is possible to find directly from the identifier.
2021-01-31Remove unnecessary `ci0` variables; ref #5272dearblue
2021-01-31Remove unnecessary configuration macros; ref #5060dearblue
The following macros will be removed: - `ENSURE_STACK_INIT_SIZE` - `RESCUE_STACK_INIT_SIZE` - `MRB_ECALL_DEPTH_MAX`
2021-01-28Merge pull request #5307 from dearblue/stackerrYukihiro "Matz" Matsumoto
Raise SystemStackError if mruby VM stack expansion fails
2021-01-28Raise SystemStackError if mruby VM stack expansion failsdearblue
2021-01-28Check first `0` when converting symbols into stringsdearblue
This was because it caused `SIGSEGV` when `mruby -v` displayed an unnamed variable. ```console % bin/mruby -ve 'call { |(a, b)| }' ...SNIP... irep 0x8007d0050 nregs=3 nlocals=1 pools=0 syms=1 reps=1 iseq=12 file: -e 1 000 OP_LOADSELF R1 1 002 OP_BLOCK R2 I(0:0x8007d00a0) 1 005 OP_SENDB R1 :call 0 1 009 OP_RETURN R1 1 011 OP_STOP irep 0x8007d00a0 nregs=6 nlocals=5 pools=0 syms=0 reps=0 iseq=29 local variable names: zsh: segmentation fault (core dumped) bin/mruby -ve 'call { |(a, b)| }' ```
2021-01-28Silence VC warning.Yukihiro "Matz" Matsumoto