summaryrefslogtreecommitdiffhomepage
path: root/src/gc.c
AgeCommit message (Collapse)Author
2017-05-25Avoid marking possibly freed stack; #3550 #3612Yukihiro "Matz" Matsumoto
2017-05-23Simplify backtrace mechanism; fix #3633 #3634 #3644Yukihiro "Matz" Matsumoto
Instead of preserving a backtrace in `mrb_state`, `mrb_exc_set` keeps packed backtrace in an exception object. `#backtrace` unpacks it to an array of strings.
2017-05-23Remove class info from backtrace lines.Yukihiro "Matz" Matsumoto
2017-05-23Use index in `each_object`.Yukihiro "Matz" Matsumoto
2017-04-25Stop invoking GC before `each_object` to avoid test failure; #3616Yukihiro "Matz" Matsumoto
2017-04-25Prevent GC during `each_object`; fix #3616Yukihiro "Matz" Matsumoto
2017-04-25Should terminate nested iterations in each_object; ref #3359Yukihiro "Matz" Matsumoto
2017-04-25Revert "Disable GC during `gc_each_objects()`; fix #3616"Yukihiro "Matz" Matsumoto
This reverts commit d2cad9ac5b8db89fc9d21f5795846f983236798c.
2017-04-25Use fiber marking instead of `mark_context`.Yukihiro "Matz" Matsumoto
To avoid redundant `mark_context()`.
2017-04-22Keep reference to mrb_context from env; fix #3619Yukihiro "Matz" Matsumoto
2017-04-21Revert e8dca6b03; fix #3550Yukihiro "Matz" Matsumoto
Reopens #3612.
2017-04-21Revert ae4217e81; fix #3619Yukihiro "Matz" Matsumoto
Reopens #3550. Those 2 issues are exclusive.
2017-04-20Disable GC during `gc_each_objects()`; fix #3616Yukihiro "Matz" Matsumoto
2017-04-20Allow `mrb_objspace_each_objects()` to break iteration; ref #3359Yukihiro "Matz" Matsumoto
2017-04-18Fixed a wrong condition; fix #3550Yukihiro "Matz" Matsumoto
Shared TT_ENV should be unshared. Reversed condition.
2017-04-18Revert 6dd1a57; fix #3612; ref #3550Yukihiro "Matz" Matsumoto
The fix was wrong. It causes a new problem #3612.
2017-04-17Mark whole root objects in final_marking_phase(); fix #3603Yukihiro "Matz" Matsumoto
ref #1359 #1362
2017-04-11Shared TT_ENV may need to be marked; fix #3550Yukihiro "Matz" Matsumoto
2017-04-10Protect arguments from GC; fix #3597Yukihiro "Matz" Matsumoto
GC may be called with OP_ENTER (especially when GC_STRESS is set).
2017-04-10Clear unused stack region that may refer freed objects; fix #3596Yukihiro "Matz" Matsumoto
2017-04-10Skip stack marking at all if c->stack is NULL.Yukihiro "Matz" Matsumoto
2017-04-05Use stderr for debug prints in DEBUG(); fix #3584Yukihiro "Matz" Matsumoto
2017-04-03Protect ensure clause lambdas from GC; fix #3491Yukihiro "Matz" Matsumoto
2017-04-03Add `struct REnv` to union `RVALUE`; ref #3534Yukihiro "Matz" Matsumoto
2017-03-04Avoid tracing shared TT_ENV object.Yukihiro "Matz" Matsumoto
2017-02-15Preallocate SystemStackError; ref #3421Yukihiro "Matz" Matsumoto
2017-02-08Mark classes referenced from saved backtrace.Yukihiro "Matz" Matsumoto
Maybe related to #3438
2017-02-04No need to make env unshared in the finalization; fix #3425Yukihiro "Matz" Matsumoto
2017-02-04Mark `mrb->backtrace.exc` as GC root; fix #3388Yukihiro "Matz" Matsumoto
2016-12-10Merge pull request #3329 from bouk/reuseYukihiro "Matz" Matsumoto
Mark all the built-in classes during GC sweep
2016-12-10gc.c: dead_slot is boolean; ref #3339Yukihiro "Matz" Matsumoto
2016-12-10do not destroy a page with an active TT_ENV (e.g. an env referred from TT_FIBER)Kazuho Oku
2016-12-08fix issues of mrb_gc_unregister introduced in 09b1185Kazuho Oku
* fixes partial copy of objects in GC root array (due to missing `* sizeof(mrb_value)`) * restores the behavior that permitted an unregistered object to be used as an argument
2016-12-07Mark all the built-in classes during GC sweepBouke van der Bijl
Reported by https://hackerone.com/haquaman
2016-12-06Add type check for cls before allocationYukihiro "Matz" Matsumoto
2016-11-30check ttype before object allocation; fix #3294Yukihiro "Matz" Matsumoto
2016-11-28pre-allocate arena overflow errorYukihiro "Matz" Matsumoto
2016-10-28should not unshare() reclaimed env objects; fix #3230Yukihiro "Matz" Matsumoto
2016-09-28Removed trailing spacesNobuyoshi Nakada
2016-06-29Fix compilation error with GC_PROFILE.Yuji Yamano
2016-06-10mrb_gc_unregister() to remove one registration; close #3160Yukihiro "Matz" Matsumoto
when multiple mrb_gc_register() were called for the same object
2016-03-06Fix segmentation fault by backtrace and GCKouhei Sutou
GitHub: fix #3122 It reverts #3126. #3126 fixes the segmentation fault but generates broken backtrace. This change fixes the segmentation fault and generates correct backtrace. The strategy of this change is "generating backtrace while irep is alive". /tmp/test.rb: def gen e0 = nil begin 1.times { raise 'foobar' } rescue => e e0 = e end e0 end e = gen GC.start gen GC.start puts e.backtrace.join("\n") Run: % bin/mruby /tmp/test.rb /tmp/test.rb:5:in Object.gen /home/kou/work/ruby/mruby.kou/mrblib/numeric.rb:77:in Integral#times /tmp/test.rb:4:in Object.gen /tmp/test.rb:13 FYI: % ruby -v /tmp/test.rb ruby 2.3.0p0 (2015-12-25) [x86_64-linux-gnu] /tmp/test.rb:5:in `block in gen' /tmp/test.rb:4:in `times' /tmp/test.rb:4:in `gen' /tmp/test.rb:13:in `<main>'
2016-02-17need to free context when reclaiming fiber object in GC; fix #3109Yukihiro "Matz" Matsumoto
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
2015-12-31GC must scan env from fibers even when it's not yet copied to heap; fix #3063Yukihiro "Matz" Matsumoto
2015-11-27include changed from by quotes ("") to by brackets (<>); close #3032Yukihiro "Matz" Matsumoto
2015-11-06remove returncremno
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-21Merge upstreamfurunkel
2015-10-20Prefix mrb_gc_state enum members, make color defines privatefurunkel
2015-10-19Remove gc_ prefix of mrb_gc fieldsfurunkel