Skip to content
Commits on Feb 5, 2016
  1. @matz
  2. @matz
  3. @matz
Commits on Feb 4, 2016
  1. @matz
  2. @matz

    cache mrb_regexp_p(); ref #980

    matz committed
  3. @matz

    Merge pull request #3096 from hlogmans/master

    matz committed
    Fix missing dependency on mruby-print to support 'puts'
Commits on Feb 3, 2016
  1. @hlogmans
Commits on Jan 31, 2016
  1. @matz

    Merge pull request #3093 from retrage/retrage/dev

    matz committed
    Add String#rjust to mruby-string-ext
  2. @matz

    Merge pull request #3092 from kenhys/fix-suported

    matz committed
    Fix a typo
Commits on Jan 30, 2016
  1. @kenhys

    Fix a typo

    kenhys committed
    su ported ->
    supported
      ^
  2. @retrage
  3. @retrage
Commits on Jan 28, 2016
  1. @matz

    Merge pull request #3091 from visualsayed/fix_hash_replace_method

    matz committed
    protect NoMethodError from calling to_hash in replace
Commits on Jan 27, 2016
  1. @visualsayed
Commits on Jan 21, 2016
  1. @matz

    Merge pull request #3090 from kou/fix-segv-by-stack-extension-in-mrb-…

    matz committed
    …get-args
    
    Fix SEGV by stack extension in mrb_get_args()
  2. @kou

    Fix SEGV by stack extension in mrb_get_args()

    kou committed
    mrb_get_args() keeps pointer of the current stack. But address of the
    current stack maybe changed by method call.
    
    'i' format character calls #to_i when the argument isn't integer but
    has #to_i.
    
    Here is a code that may call #to_i in mrb_get_args():
    
        case 'i':
          // ...
                default:
                  *p = mrb_fixnum(mrb_Integer(mrb, ARGV[arg_i]));
                  break;
         // ...
    
    Here is a code #to_i is called:
    
        class X
          def initialize(i)
            @i = i
          end
    
          def to_i
            @i
          end
        end
    
        [][X.new(0), 0] # X#to_i is called
    
    So, mrb_get_args() shouldn't keep pointer and use it. mrb_get_args()
    should always refer mrb->ci->stack to use valid address of the current
    stack.
Commits on Jan 20, 2016
  1. @matz
  2. @matz

    Merge pull request #3088 from maclover7/patch-1

    matz committed
    Small grammar fix
  3. @maclover7

    Small grammar fix

    maclover7 committed
    [ci skip]
Commits on Jan 19, 2016
  1. @matz

    Merge pull request #3087 from kou/fix-segv-on-rerasing-no-memory-error

    matz committed
    Fix SEGV on re-raising NoMemoryError
  2. @kou

    Fix SEGV on re-raising NoMemoryError

    kou committed
    Think about the following Ruby script:
    
    segv.rb:
    
        begin
          lambda do
            lambda do
              "x" * 1000 # NoMemoryError
            end.call
          end.call
        rescue
          raise
        end
    
    If memory can't allocate after `"x" * 1000`, mruby crashes.
    
    Because L_RAISE: block in mrb_vm_exec() calls mrb_env_unshare() via
    cipop() and mrb_env_unshare() uses allocated memory without NULL check:
    
    L_RAISE: block:
    
        L_RAISE:
          // ...
          while (ci[0].ridx == ci[-1].ridx) {
            cipop(mrb);
            // ...
          }
    
    cipop():
    
        static void
        cipop(mrb_state *mrb)
        {
          struct mrb_context *c = mrb->c;
    
          if (c->ci->env) {
            mrb_env_unshare(mrb, c->ci->env);
          }
    
          c->ci--;
        }
    
    mrb_env_unshare():
    
        MRB_API void
        mrb_env_unshare(mrb_state *mrb, struct REnv *e)
        {
          size_t len = (size_t)MRB_ENV_STACK_LEN(e);
          // p is NULL in this case
          mrb_value *p = (mrb_value *)mrb_malloc(mrb, sizeof(mrb_value)*len);
    
          MRB_ENV_UNSHARE_STACK(e);
          if (len > 0) {
            stack_copy(p, e->stack, len); // p is NULL but used. It causes SEGV.
          }
          e->stack = p;
          mrb_write_barrier(mrb, (struct RBasic *)e);
        }
    
    To solve the SEGV, this change always raises NoMemoryError even when
    realloc() is failed after the first NoMemoryError in
    mrb_realloc(). mrb_unv_unshare() doesn't need to check NULL with this
    change.
    
    But it causes infinite loop in the following while:
    
        L_RAISE:
          // ...
          while (ci[0].ridx == ci[-1].ridx) {
            cipop(mrb);
            // ...
          }
    
    Because cipop() never pops ci.
    
    This change includes cipop() change. The change pops ci even when
    mrb_unv_unshare() is failed by NoMemoryError.
    
    This case can be reproduced by the following program:
    
        #include <stdlib.h>
        #include <mruby.h>
        #include <mruby/compile.h>
    
        static void *
        allocf(mrb_state *mrb, void *ptr, size_t size, void *ud)
        {
          static mrb_bool always_fail = FALSE;
    
          if (size == 1001) {
            always_fail = TRUE;
          }
          if (always_fail) {
            return NULL;
          }
    
          if (size == 0) {
            free(ptr);
            return NULL;
          } else {
            return realloc(ptr, size);
          }
        }
    
        int
        main(int argc, char **argv)
        {
          mrb_state *mrb;
          mrbc_context *c;
          FILE *file;
    
          mrb = mrb_open_allocf(allocf, NULL);
          c = mrbc_context_new(mrb);
          file = fopen(argv[1], "r");
          mrb_load_file_cxt(mrb, file, c);
          fclose(file);
          mrbc_context_free(mrb, c);
          mrb_close(mrb);
    
          return EXIT_SUCCESS;
        }
    
    Try the following command lines:
    
        % cc -I include -L build/host/lib -O0 -g3 -o no-memory no-memory.c -lmruby -lm
        % ./no-memory segv.rb
Commits on Jan 18, 2016
  1. @matz

    Merge pull request #3086 from pra85/2016

    matz committed
    Update license year range to 2016
  2. @pra85

    Update license year range to 2016

    pra85 committed
Commits on Jan 14, 2016
  1. @matz

    Merge pull request #3084 from syohex/all-zeros

    matz committed
    Fix passing all zero string to Kernel#Integer
  2. @syohex

    Fix all zero string case

    syohex committed
  3. @syohex
Commits on Jan 13, 2016
  1. @matz

    Merge pull request #3082 from jefffederman/feature/install-mruby-with…

    matz committed
    …-ruby-install
    
    Update README to mention ruby version management tools
  2. @jefffederman
  3. @matz

    Merge pull request #3081 from val00274/fix_toolchains_params

    matz committed
    Fix build error in ruby 1.8.
  4. @val00274

    Fix build error in ruby 1.8.

    val00274 committed
    Apply change of #2978 to :clang, :gcc, :visualcpp toolchains
Commits on Jan 11, 2016
  1. @matz

    Merge pull request #3080 from kou/fix-class-variable-in-module

    matz committed
    Fix class variable reference in module
Commits on Jan 10, 2016
  1. @kou
Commits on Jan 8, 2016
  1. @matz
Commits on Jan 7, 2016
  1. @matz

    Merge pull request #3077 from sgnr/output-backtrace-segfault

    matz committed
    Fix segfault on mrb_exc_backtrace.
  2. @sgnr

    Fix segfault on mrb_exc_backtrace.

    sgnr committed
    The code to iterate over backtrace locations was changed in #3065, but
    unfortunately output_backtrace was not correctly updated to forward the
    callback.
Something went wrong with that request. Please try again.