| Age | Commit message (Collapse) | Author | |
|---|---|---|---|
| 2016-01-19 | Fix SEGV on re-raising NoMemoryError | Kouhei 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 | |||
| 2015-12-31 | GC must scan env from fibers even when it's not yet copied to heap; fix #3063 | Yukihiro "Matz" Matsumoto | |
| 2015-11-27 | include changed from by quotes ("") to by brackets (<>); close #3032 | Yukihiro "Matz" Matsumoto | |
| 2015-11-06 | remove return | cremno | |
| The return type of the mrb_objspace_each_objects function is void. So this return statement with an expression is unnecessary and also violates a constraint. From C99 §6.8.6.4: >A return statement with an expression shall not appear >in a function whose return type is void. | |||
| 2015-10-21 | Merge upstream | furunkel | |
| 2015-10-20 | Prefix mrb_gc_state enum members, make color defines private | furunkel | |
| 2015-10-19 | Remove gc_ prefix of mrb_gc fields | furunkel | |
| 2015-10-19 | Move MRB_GC_ARENA_SIZE to gc.h and fix compiler warnings | furunkel | |
| 2015-10-19 | Remove segregated value struct declaration | furunkel | |
| 2015-10-19 | Clean up GC code | furunkel | |
| 2015-09-22 | add new functions mrb_gc_register/unregister; close #1411 | Yukihiro "Matz" Matsumoto | |
| some routines need to refer mruby objects (e.g. callbacks), in that case you have to protect your objects from garbage collection. the new functions mrb_gc_register() keeps those objects from GC. you have to remove your objects using mrb_gc_unregister() when your C routines use mruby objects any longer, otherwise objects will leak. | |||
| 2015-07-14 | Applied gc patch to fix ORIGIN ICLASS method table leak | Corey Powell | |
| Based on the gc patch by ko1 https://github.com/ruby/ruby/commit/5922c954614e5947a548780bb3b894626affe6dd | |||
| 2014-10-02 | cast MRB_ENV_STACK_LEN to (mrb_int); ref #2600 | Yukihiro "Matz" Matsumoto | |
| 2014-08-29 | Fix mismatches for MRB_API declarations. | Tatsuhiko Kubo | |
| 2014-08-27 | Merge pull request #2567 from cubicdaiya/issues/space_after_comma2 | Yukihiro "Matz" Matsumoto | |
| Add a missing space after ",". | |||
| 2014-08-27 | Add a missing space after ",". | Tatsuhiko Kubo | |
| 2014-08-27 | Use mrb_malloc() instead of mrb_realloc(). | Tatsuhiko Kubo | |
| 2014-08-27 | Remove discareded NULL checks. | Tatsuhiko Kubo | |
| 2014-08-07 | Fix typo in gc.c | Jun Hiroe | |
| 2014-08-07 | Merge pull request #2512 from suzukaze/gc-state-root | Yukihiro "Matz" Matsumoto | |
| Rename GC_STATE_NONE GC_STATE_ROOT | |||
| 2014-08-06 | Refactor incremental_sweep_phase() in gc.c | Jun Hiroe | |
| 2014-08-06 | Rename GC_STATE_NONE GC_STATE_ROOT | Jun Hiroe | |
| 2014-08-05 | Refactor obj_free() in gc.c | Jun Hiroe | |
| 2014-08-05 | write barrier doc update | Yukihiro "Matz" Matsumoto | |
| 2014-08-05 | Merge branch 'add-gc-docs' of https://github.com/suzukaze/mruby into ↵ | Yukihiro "Matz" Matsumoto | |
| suzukaze-add-gc-docs | |||
| 2014-08-05 | Add write_barrier docs | Jun Hiroe | |
| 2014-08-04 | Merge branch 'master' of github.com:mruby/mruby | Yukihiro "Matz" Matsumoto | |
| 2014-08-03 | fix conversion warnings | cremno | |
| Those warnings are not enabled by default, but getting rid of them doesn't hurt. | |||
| 2014-08-04 | rename obsolete mrb_special_const_p to mrb_immediate_p | Yukihiro "Matz" Matsumoto | |
| 2014-08-04 | add MRB_API modifiers to mruby API functions | Yukihiro "Matz" Matsumoto | |
| 2014-07-24 | Merge pull request #2477 from take-cheeze/allocf_ud | Yukihiro "Matz" Matsumoto | |
| Add field `allocf_ud` to replace current `ud`. | |||
| 2014-07-21 | Use MRB_TT_EXCEPTION in exception object. | take_cheeze | |
| 2014-07-17 | Add field `allocf_ud` to replace current `ud`. | take_cheeze | |
| Since some use it as `mrb_state` associated user data. | |||
| 2014-07-02 | Ensure RVALUE is large enough for word boxing types. | David Turnbull | |
| 2014-06-04 | mark pre-allocated exception | Yukihiro "Matz" Matsumoto | |
| 2014-06-04 | use pre-allocated RuntimeError for out-of-memory | Yukihiro "Matz" Matsumoto | |
| 2014-06-03 | Fix typos in gc | katmutua | |
| 2014-05-03 | Fix indent | Jun Hiroe | |
| 2014-04-29 | stack may be uncleared | Yukihiro "Matz" Matsumoto | |
| 2014-04-29 | fiber context may be NULL | Yukihiro "Matz" Matsumoto | |
| 2014-04-27 | forgot to remove abort() | Yukihiro "Matz" Matsumoto | |
| 2014-04-27 | mark may be missed when eval() is called | Yukihiro "Matz" Matsumoto | |
| 2014-04-24 | Fix MSVC warning for gc.c | kyab | |
| 2014-04-01 | Use MRB_ENV_STACK_SHARED_P to check `cioff` field of REnv. | take_cheeze | |
| 2014-04-01 | Use MRB_ENV_STACK_LEN instead of accessing `flags` directly to get REnv's ↵ | take_cheeze | |
| stack length. | |||
| 2014-03-18 | mark root fiber object; close #1865 | Yukihiro "Matz" Matsumoto | |
| 2014-03-10 | add comments at end of include guard | cubicdaiya | |
| 2014-02-28 | remove break altogether in ci loop | Yukihiro "Matz" Matsumoto | |
| 2014-02-27 | should not continue loop when ci = NULL | Yukihiro "Matz" Matsumoto | |
| 2014-02-09 | Merge pull request #1674 from cremno/mrb_bool-FALSE-TRUE | Yukihiro "Matz" Matsumoto | |
| use mrb_bool, FALSE and TRUE more | |||
