summaryrefslogtreecommitdiffhomepage
path: root/src/vm.c
AgeCommit message (Collapse)Author
2017-01-21Stack position may be bigger than stack bottom; fix #3401Yukihiro "Matz" Matsumoto
This issue was reported by https://hackerone.com/titanous
2017-01-18Initialize callinfo->acc; ref #3243Yukihiro "Matz" Matsumoto
2017-01-12Add proper given argument number in the wrong-number-argument error.Yukihiro "Matz" Matsumoto
2017-01-12Add proper stack size calculation; fix #3398Yukihiro "Matz" Matsumoto
This issue was reported by https://hackerone.com/ssarong
2017-01-11Use temporary variable to avoid potential crash; fix #3387Yukihiro "Matz" Matsumoto
This issue was original reported by https://hackerone.com/icanthack https://hackerone.com/titanous suggested the solution. `regs` may be reallocated in the function call.
2017-01-11Check if ci->target_class is NULL before dereferencingYukihiro "Matz" Matsumoto
close #3389 This issue was reported by https://hackerone.com/ston3
2017-01-02use size_t instead of intYukihiro "Matz" Matsumoto
2016-12-30method_missing() may have CALL_MAXARGS-1 arguments; fix #3351Yukihiro "Matz" Matsumoto
The issue was reported by https://hackerone.com/ston3
2016-12-13Restore callinfo offset in mrb_yield_with_class()Yukihiro "Matz" Matsumoto
2016-12-05Merge pull request #3318 from bouk/splat-stackYukihiro "Matz" Matsumoto
Fix stack move segfaulting in OP_ARYCAT
2016-12-03Merge branch 'method-missing-segfault' of https://github.com/bouk/mruby into ↵Yukihiro "Matz" Matsumoto
bouk-method-missing-segfault
2016-12-01Fix stack move segfaulting in OP_ARYCATBouke van der Bijl
Reported by https://hackerone.com/haquaman Testcase (couldn't get it to work as a test): def nil.b b *nil end nil.b
2016-11-24Fix instances where return value of mrb_method_search_vm is uncheckedFrancois Chagnon
Reported by @charliesome
2016-11-24Fix segfault when defining class inside instance_exec on primitiveBouke van der Bijl
2016-11-07fixed wrong stack adjustment for ensure clauses; fix #3175Yukihiro "Matz" Matsumoto
2016-11-05associate REnv to the executing block; fix #3214Yukihiro "Matz" Matsumoto
2016-10-20Move to_proc conversion from OP_ENTER to OP_SENDB; fix #3227Yukihiro "Matz" Matsumoto
2016-09-20Fix return value type of bytecode_decoderKazuaki Tanaka
2016-09-20Bytecode decoder support, MRB_BYTECODE_DECODE_OPTIONKazuaki Tanaka
2016-09-06surpress warning when MRB_DISABLE_STDIOyuri
2016-09-05Should clear method nameksss
- Fix method name in top-level - Fix SEGV when call Exception#backtrace if callinfo over CALLINFO_INIT_SIZE(32)
2016-07-14Should raise LocalJumpError when no block givenksss
2016-05-10use mrb_int_mul_overflow()cremno
2016-05-09Remove needless assignmentKouhei Sutou
d4ee409ae912dec6eb719a5727da4566f817d9d8 should remove this line.
2016-04-27Use stack directlyKenji Okimoto
See https://github.com/mruby/mruby/pull/3142#issuecomment-201138873
2016-04-11vm.c: mrb_hash_set() may reallocate VM stack; close #3133Yukihiro "Matz" Matsumoto
2016-03-25Add missing regs updateKouhei Sutou
mrb_vm_define_class() may realloc() mrb->c->stack because it calls mrb_funcall() for inherited hook. If mrb->c->stack is realloc()-ed, regs refers orphan address.
2016-01-19Fix SEGV on re-raising NoMemoryErrorKouhei Sutou
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
2016-01-07change mrb_run related API names; compatibility macros providedYukihiro "Matz" Matsumoto
2016-01-04stack_extend before eval_under()Yukihiro "Matz" Matsumoto
2016-01-02instance_eval should pass the receiver as a block parameter; close #3029Yukihiro "Matz" Matsumoto
2016-01-02mruby-fiber: fiber_switch() to use nesting VM when it's called from C API or ↵Yukihiro "Matz" Matsumoto
mrb_funcall(); close #3056
2015-12-31GC must scan env from fibers even when it's not yet copied to heap; fix #3063Yukihiro "Matz" Matsumoto
2015-12-29Support backtrace after method callsKouhei Sutou
GitHub: fix #2902, #2917 The current implementation traverses stack to retrieve backtrace. But stack will be changed when some operations are occurred. It means that backtrace may be broken after some operations. This change (1) saves the minimum information to retrieve backtrace when exception is raised and (2) restores backtrace from the minimum information when backtrace is needed. It reduces overhead for creating backtrace Ruby objects. The space for the minimum information is reused by multiple exceptions. So memory allocation isn't occurred for each exception.
2015-11-27include changed from by quotes ("") to by brackets (<>); close #3032Yukihiro "Matz" Matsumoto
2015-11-17DISABLE_STDIO/ENABLE_DEBUG macros to rename; close #3014Yukihiro "Matz" Matsumoto
changes: * rename DISABLE_STDIO -> MRB_DISABLE_STDIO * rename ENABLE_DEBUG -> MRB_ENABLE_DEBUG_HOOK * no more opposite macro definitions (e.g. ENABLE_STDIO, DISABLE_DEBUG). * rewrite above macro references throughout the code. * update documents
2015-11-07PR #2521 did not work for singleton classes for non-class objects; fix #3003Yukihiro "Matz" Matsumoto
2015-10-27mrb_str_concat() may call VM resursively thus may reallocate VM stack; close ↵Yukihiro "Matz" Matsumoto
#3000
2015-10-19Clean up GC codefurunkel
2015-09-02ensure must not be called before rescue; fix #2933Yukihiro "Matz" Matsumoto
2015-08-10prevent out-of-bounds ensure clause access; fix #2910Yukihiro "Matz" Matsumoto
2015-07-30vm: execute ensure without exception at the top of the fiber; fix #2904Yukihiro "Matz" Matsumoto
2015-07-30vm: execute ensure at the top of the fiber; fix #2903Yukihiro "Matz" Matsumoto
2015-07-13refactor mrb_bob_missing to share raising NoMethodError code; fix #2878Yukihiro "Matz" Matsumoto
Note: arguments of mrb_no_method_error() has changed. You need to replace 3rd and 4th argument (say n, argv) to mrb_ary_new_from_values(mrb, n, argv).
2015-07-07method_missing definition may be undefined; fix #2878Yukihiro "Matz" Matsumoto
2015-05-31fix OP_APOST bug for no pre arg cases; fix #2810Yukihiro "Matz" Matsumoto
2015-05-25Move "src/mrb_throw.h" to "include/mruby/throw.h".take_cheeze
Related to #2760.
2015-05-15remove mrb_define_method_vm() functioncremno
It isn't needed as it's very similar to mrb_define_method_raw() and also there's only one place where mrb_proc_ptr() actually has to be called. Inspired by @furunkel's method cache patch (#2764).
2015-04-27C++ compilation failed due to skipping iniitalization by goto out_superYukihiro "Matz" Matsumoto
2015-04-27super should not be called outside of a method; fix #2770Yukihiro "Matz" Matsumoto