summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)Author
2021-02-11Merge pull request #5333 from ↵Yukihiro "Matz" Matsumoto
shuujii/fix-heap-buffer-overflow-for-small-Hash-HT-in-Hash-rehash Fix heap-buffer-overflow for small `Hash` (HT) in `Hash#rehash`
2021-02-10Merge branch 'dearblue-mruby-catch'Yukihiro "Matz" Matsumoto
2021-02-10Refactor `mruby-catch`; ref #5328Yukihiro "Matz" Matsumoto
- Move `#catch` definition to `mruby-catch.c` to avoid tweaking - Remove `#__preserve_catch_method` - Implement whole `#throw` method in C
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-10Merge branch 'mruby-catch' of https://github.com/dearblue/mruby into ↵Yukihiro "Matz" Matsumoto
dearblue-mruby-catch
2021-02-09Upgrade supported Ruby version to 2.5.Yukihiro "Matz" Matsumoto
Ruby 2.5 is the oldest maintained version.
2021-02-08`i_gcd()` does not work for `MRB_INT_MIN`.Yukihiro "Matz" Matsumoto
2021-02-08Allow the case `MRB_32BIT` and `MRB_NO_BOXING` and `MRB_USE_FLOAT32`; #4382Yukihiro "Matz" Matsumoto
2021-02-08Merge pull request #5331 from ↵Yukihiro "Matz" Matsumoto
shuujii/explicit-top-level-task-to-clarify-in-tasks-test.rake Explicit top level task to clarify in `tasks/test.rake`
2021-02-07Explicit top level task to clarify in `tasks/test.rake`KOBAYASHI Shuji
2021-02-07Move `F(x)` definition inside of `#ifdef`; fix #5330Yukihiro "Matz" Matsumoto
2021-02-07Enlarge tolerance limit for `float32`; close #5329Yukihiro "Matz" Matsumoto
Along with some refactoring on `mruby-math` tests.
2021-02-07Fix tests to work with `MRB_USE_FLOAT32`; fix #5329Yukihiro "Matz" Matsumoto
2021-02-07Add `host-f32` config to test `MRB_USE_FLOAT32`; ref #5329Yukihiro "Matz" Matsumoto
2021-02-06Reimplement mruby-catch; ref #5321dearblue
When there is a corresponding tag, the `RBreak` object is used to make a global jump. Like CRuby, it can't be caught by `rescue`. It is also the same as CRuby that it can be canceled in the middle by `ensure`. ### How to find the corresponding tag with `throw` The called `catch` method remains in the call stack, and the tag also remains in the stack at that time. So it is possible to find the called location by searching the two. Note that no method can be given to the `proc` object specified in `RBreak`. Therefore, inside the `catch` method, the argument block is called in a seemingly meaningless closure. Also, as a countermeasure against `alias` etc., the `proc` object, which is the body of the `catch` method, is saved when mrbgem is initialized.
2021-02-06MinGW does not need MSVC hack.Yukihiro "Matz" Matsumoto
Both MinGW and MSVC provide _WIN32 macro.
2021-02-06Merge pull request #5325 from dearblue/c++-exc.2Yukihiro "Matz" Matsumoto
`compile_as_cxx` should generate a path under` conf.build_dir`
2021-02-06Merge pull request #5327 from dearblue/notestYukihiro "Matz" Matsumoto
Ignore if `conf.enable_test` does not exist
2021-02-06Merge pull request #5326 from dearblue/structYukihiro "Matz" Matsumoto
No need to check class definition
2021-02-06Ignore if `conf.enable_test` does not existdearblue
Because if the configuration file didn't contain any `conf.enable_test`, `rake test` would report an exception and exit. ```console % cat my_config.rb MRuby::Build.new { toolchain } % rake MRUBY_CONFIG=my_config.rb test ...SNIP... rake aborted! NoMethodError: undefined method `invoke' for nil:NilClass /var/tmp/mruby/tasks/test.rake:24:in `block (3 levels) in <top (required)>' Tasks: TOP => test => test:build => test:build:lib (See full trace by running task with --trace) ```
2021-02-06No need to check class definitiondearblue
Because now the `Struct` class is always defined when this file is included.
2021-02-06`compile_as_cxx` should generate a path under` conf.build_dir`dearblue
If the current directory is different from `MRUBY_ROOT` and it has` conf.build_dir` and `conf.enable_cxx_exception` set, it was generating a pathname outside of` build_dir`. As a result, in some cases files unrelated to mruby could be linked. ```console % pwd /tmp/mruby/1/2/3/4/5/6 % mruby_dir=/tmp/mruby/a/b/c/d/mruby % cat my_config.rb MRuby::Build.new("host", "build/to/custom/directory") do toolchain enable_cxx_exception end % rake MRUBY_CONFIG=my_config.rb -f $mruby_dir/Rakefile > logs % grep CXX logs CXX a/b/c/d/mruby/src/error-cxx.cxx -> a/b/c/d/mruby/src/error-cxx.o CXX a/b/c/d/mruby/src/gc-cxx.cxx -> a/b/c/d/mruby/src/gc-cxx.o CXX a/b/c/d/mruby/src/vm-cxx.cxx -> a/b/c/d/mruby/src/vm-cxx.o CXX a/b/c/d/mruby/mrbgems/mruby-compiler/core/codegen-cxx.cxx -> a/b/c/d/mruby/mrbgems/mruby-compiler/core/codegen-cxx.o CXX a/b/c/d/mruby/mrbgems/mruby-compiler/core/y.tab-cxx.cxx -> a/b/c/d/mruby/mrbgems/mruby-compiler/core/y.tab-cxx.o CXX ../a/b/c/d/mruby/src/error-cxx.cxx -> ../a/b/c/d/mruby/src/error-cxx.o CXX ../a/b/c/d/mruby/src/gc-cxx.cxx -> ../a/b/c/d/mruby/src/gc-cxx.o CXX ../a/b/c/d/mruby/src/vm-cxx.cxx -> ../a/b/c/d/mruby/src/vm-cxx.o ```
2021-02-06Fixed compile errors in `cmath.c` in MinGW and macOS.Yukihiro "Matz" Matsumoto
2021-02-06Merge pull request #5324 from dearblue/c++-excYukihiro "Matz" Matsumoto
Exclude `<build-dir>/mrbc/**/*` from rake target rules
2021-02-06Merge pull request #5323 from ↵Yukihiro "Matz" Matsumoto
shuujii/make-the-argument-of-Kernel-catch-optional-as-Ruby-does Make the argument of `Kernel#catch` optional as Ruby does
2021-02-06Exclude `<build-dir>/mrbc/**/*` from rake target rulesdearblue
Prevents the auto-generated mrbc target source code from being compiled under host conditions. This is because a build error occurred when `conf.enable_cxx_exception` was set.
2021-02-06Make the argument of `Kernel#catch` optional as Ruby doesKOBAYASHI Shuji
Also implement the following changes. * Add tests * Use `Object#equal?` to compare tags for Ruby compatibility * Use `attr_reader`
2021-02-06Avoid implicit conversion from `mrb_float` to `mrb_complex`.Yukihiro "Matz" Matsumoto
2021-02-06Merge pull request #5322 from ↵Yukihiro "Matz" Matsumoto
shuujii/fix-message-of-ThrowCatchJump-in-mruby-catch-gem Fix message of `ThrowCatchJump` in `mruby-catch` gem
2021-02-06Reimplement complex division.Yukihiro "Matz" Matsumoto
2021-02-06Define `M_E` for some platforms.Yukihiro "Matz" Matsumoto
2021-02-06Update `mruby-cmath` to support MSVC complex.Yukihiro "Matz" Matsumoto
* Use `_Complex` instead of `complex` (MSYS2 do not support `complex`) * Use `_Dcomplex` instead of `_Complex` on MSCV * Avoid operator division and multiplication of complex
2021-02-05Fix message of `ThrowCatchJump` in `mruby-catch` gemKOBAYASHI Shuji
### Example ```ruby begin throw 1 rescue Exception => e puts e.message end ``` #### Before this patch: ```console $ bin/mruby example.rb uncaught throw :1 ``` #### After this patch (same as Ruby): ```console $ bin/mruby example.rb uncaught throw 1 ```
2021-02-05Add `mruby-cmath` gem to the core.Yukihiro "Matz" Matsumoto
This gem uses C99 `_Complex` features. You need a C compiler that supports `_Complex` to enable this gem. All `gcc`, `clang`, `VC` support `_Complex` so there should not be a big problem.
2021-02-05Add a few new API for complex access.Yukihiro "Matz" Matsumoto
2021-02-05Refactor method overriding.Yukihiro "Matz" Matsumoto
* Use `class_eval` instead of `instance_eval`. * Reduce `class_eval` calls * define `Numeric#i` * undefine `Complex#i`
2021-02-05Add `Complex#to_c` method.Yukihiro "Matz" Matsumoto
2021-02-05`instance_eval` for classes and modules should behave as `class_eval`.Yukihiro "Matz" Matsumoto
2021-02-05Define `MRB_NO_GEMS` if `disable_libmruby` is specifiedKOBAYASHI Shuji
2021-02-04Merge pull request #5319 from shuujii/check-if-.pi-build-rules-are-definedYukihiro "Matz" Matsumoto
Check if `.pi` build rules are defined
2021-02-04Check if `.pi` build rules are definedKOBAYASHI Shuji
`.pi` files are created for `.o` files that `build.products` depends on, but an error will occur if the build rule is unknown, so add a check. I don't think this situation would normally arise. However, in `mattn/mruby-onig-regexp`, when using bundled onigmo, onigmo's `.o` files are added to dependency of `libmruby.a` in the second and subsequent builds, and mruby does not know the build rule, so the following error had occured. ```console rake aborted! Don't know how to build task '/mruby/build/host/mrbgems/mruby-onig-regexp/onigmo-6.2.0/libonig_objs/ascii.pi' (See the list of available tasks with `rake --tasks`) ```
2021-02-04Merge pull request #5318 from ↵Yukihiro "Matz" Matsumoto
shuujii/fix-breakage-where-builds-except-host-dont-refer-mrbc-in-host Fix breakage where builds except `host` don't refer` mrbc` in `host`
2021-02-04Fix breakage where builds except `host` don't refer` mrbc` in `host`KOBAYASHI Shuji
Build error occurred under the following conditions. * `host` build is presym enabled and unspecified `mruby-bin-mrbc` gem. * Build except `host` unspecified `mruby-bin-mrbc` gem and mrbcfile. ### Example #### Build configuration ```ruby MRuby::Build.new{|conf| conf.toolchain} MRuby::Build.new("host2"){|conf| conf.toolchain} ``` #### Error ```console rake aborted! external mrbc or mruby-bin-mrbc gem in current('host2') or 'host' build is required /mruby/lib/mruby/build.rb:326:in `mrbcfile' /mruby/tasks/mrblib.rake:9:in `block in <top (required)>' /mruby/lib/mruby/build.rb:18:in `instance_eval' /mruby/lib/mruby/build.rb:18:in `block in each_target' /mruby/lib/mruby/build.rb:17:in `each' /mruby/lib/mruby/build.rb:17:in `each_target' /mruby/tasks/mrblib.rake:1:in `<top (required)>' /mruby/Rakefile:27:in `load' /mruby/Rakefile:27:in `<top (required)>' ```
2021-02-03Update version to `3.0.0RC`.3.0.0-rcmimaki
2021-02-03Avoid Heap Overflow in `heredoc_remove_indent`; fix #5316Yukihiro "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()`