1. 12 Feb, 2021 6 commits
  2. 10 Feb, 2021 5 commits
    • Yukihiro "Matz" Matsumoto's avatar
      Merge pull request #5333 from shuujii/fix-heap-buffer-overflow-for-small-Hash-HT-in-Hash-rehash · d178e147
      Yukihiro "Matz" Matsumoto authored
      Fix heap-buffer-overflow for small `Hash` (HT) in `Hash#rehash`
      d178e147
    • Yukihiro "Matz" Matsumoto's avatar
      5735d7c2
    • Yukihiro "Matz" Matsumoto's avatar
      Refactor `mruby-catch`; ref #5328 · c7809ca0
      Yukihiro "Matz" Matsumoto authored
      - Move `#catch` definition to `mruby-catch.c` to avoid tweaking
      - Remove `#__preserve_catch_method`
      - Implement whole `#throw` method in C
      c7809ca0
    • KOBAYASHI Shuji's avatar
      Fix heap-buffer-overflow for small `Hash` (HT) in `Hash#rehash` · 28eb6271
      KOBAYASHI Shuji authored
      ### 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)
      ```
      28eb6271
    • Yukihiro "Matz" Matsumoto's avatar
  3. 09 Feb, 2021 1 commit
  4. 08 Feb, 2021 2 commits
  5. 07 Feb, 2021 6 commits
  6. 06 Feb, 2021 13 commits
    • dearblue's avatar
      Reimplement mruby-catch; ref #5321 · 232e07ad
      dearblue authored
      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.
      232e07ad
    • Yukihiro "Matz" Matsumoto's avatar
      MinGW does not need MSVC hack. · ef8f4757
      Yukihiro "Matz" Matsumoto authored
      Both MinGW and MSVC provide _WIN32 macro.
      ef8f4757
    • Yukihiro "Matz" Matsumoto's avatar
      Merge pull request #5325 from dearblue/c++-exc.2 · c6c632cf
      Yukihiro "Matz" Matsumoto authored
      `compile_as_cxx` should generate a path under` conf.build_dir`
      c6c632cf
    • Yukihiro "Matz" Matsumoto's avatar
      Merge pull request #5327 from dearblue/notest · 94d8dfed
      Yukihiro "Matz" Matsumoto authored
      Ignore if `conf.enable_test` does not exist
      94d8dfed
    • Yukihiro "Matz" Matsumoto's avatar
      Merge pull request #5326 from dearblue/struct · 6d0b5102
      Yukihiro "Matz" Matsumoto authored
      No need to check class definition
      6d0b5102
    • dearblue's avatar
      Ignore if `conf.enable_test` does not exist · 9d1a659b
      dearblue authored
      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)
      ```
      9d1a659b
    • dearblue's avatar
      No need to check class definition · 0f8d3d87
      dearblue authored
      Because now the `Struct` class is always defined when this file is included.
      0f8d3d87
    • dearblue's avatar
      `compile_as_cxx` should generate a path under` conf.build_dir` · e0d2f4e0
      dearblue authored
      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
      ```
      e0d2f4e0
    • Yukihiro "Matz" Matsumoto's avatar
    • Yukihiro "Matz" Matsumoto's avatar
      Merge pull request #5324 from dearblue/c++-exc · 2a69f510
      Yukihiro "Matz" Matsumoto authored
      Exclude `<build-dir>/mrbc/**/*` from rake target rules
      2a69f510
    • Yukihiro "Matz" Matsumoto's avatar
      Merge pull request #5323 from shuujii/make-the-argument-of-Kernel-catch-optional-as-Ruby-does · 0bd01c54
      Yukihiro "Matz" Matsumoto authored
      Make the argument of `Kernel#catch` optional as Ruby does
      0bd01c54
    • dearblue's avatar
      Exclude `<build-dir>/mrbc/**/*` from rake target rules · 5c3b5f42
      dearblue authored
      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.
      5c3b5f42
    • KOBAYASHI Shuji's avatar
      Make the argument of `Kernel#catch` optional as Ruby does · 1ea4c512
      KOBAYASHI Shuji authored
      Also implement the following changes.
      
      * Add tests
      * Use `Object#equal?` to compare tags for Ruby compatibility
      * Use `attr_reader`
      1ea4c512
  7. 05 Feb, 2021 7 commits