summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2025-03-05 14:22:01 -0500
committerPeter Zhu <[email protected]>2025-03-06 11:58:54 -0500
commit6bad47ac6d62b54fe30e3f161c2a9d8f5fa4800c (patch)
tree2ee2dd81954e9b14fb5cf40d8eb578540dd0b546 /ruby.c
parentbb91c303bad5fcdd59b73ca1a1923f71c7efdbfd (diff)
RUBY_FREE_AT_EXIT does not work when error in -r
[Bug #21173] When loading a file using the command line -r, it is processed before RUBY_FREE_AT_EXIT is checked. So if the loaded file raises an error, it will cause memory to not be freed with RUBY_FREE_AT_EXIT. For example `ruby -rtest.rb -e ""` will report a large amount of memory leaks if `test.rb` raises.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12859
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/ruby.c b/ruby.c
index 059eb6652c..db60a67ecd 100644
--- a/ruby.c
+++ b/ruby.c
@@ -3131,6 +3131,11 @@ ruby_process_options(int argc, char **argv)
ruby_init_setproctitle(argc, argv);
#endif
+ if (getenv("RUBY_FREE_AT_EXIT")) {
+ rb_free_at_exit = true;
+ rb_category_warn(RB_WARN_CATEGORY_EXPERIMENTAL, "Free at exit is experimental and may be unstable");
+ }
+
iseq = process_options(argc, argv, cmdline_options_init(&opt));
if (opt.crash_report && *opt.crash_report) {
@@ -3138,11 +3143,6 @@ ruby_process_options(int argc, char **argv)
ruby_set_crash_report(opt.crash_report);
}
- if (getenv("RUBY_FREE_AT_EXIT")) {
- rb_free_at_exit = true;
- rb_category_warn(RB_WARN_CATEGORY_EXPERIMENTAL, "Free at exit is experimental and may be unstable");
- }
-
return (void*)(struct RData*)iseq;
}