Created
June 25, 2023 14:33
-
-
Save tomstuart/d59cd53006dce11cc0d598ee31411e4c to your computer and use it in GitHub Desktop.
Read `--backtrace-limit` from `RUBYOPT`, default it to 5 and allow it to be set to -1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/error.c b/error.c | |
index 8aa081c198..d51ea349e0 100644 | |
--- a/error.c | |
+++ b/error.c | |
@@ -66,7 +66,7 @@ VALUE rb_iseqw_local_variables(VALUE iseqval); | |
VALUE rb_iseqw_new(const rb_iseq_t *); | |
int rb_str_end_with_asciichar(VALUE str, int c); | |
-long rb_backtrace_length_limit = -1; | |
+long rb_backtrace_length_limit = 5; | |
VALUE rb_eEAGAIN; | |
VALUE rb_eEWOULDBLOCK; | |
VALUE rb_eEINPROGRESS; | |
diff --git a/ruby.c b/ruby.c | |
index c27f44edb3..09556b5008 100644 | |
--- a/ruby.c | |
+++ b/ruby.c | |
@@ -1522,10 +1522,10 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt) | |
opt->dump |= DUMP_BIT(help); | |
goto switch_end; | |
} | |
- else if (is_option_with_arg("backtrace-limit", Qfalse, Qfalse)) { | |
+ else if (is_option_with_arg("backtrace-limit", Qfalse, Qtrue)) { | |
char *e; | |
long n = strtol(s, &e, 10); | |
- if (errno == ERANGE || n < 0 || *e) rb_raise(rb_eRuntimeError, "wrong limit for backtrace length"); | |
+ if (errno == ERANGE || n < -1 || *e) rb_raise(rb_eRuntimeError, "wrong limit for backtrace length"); | |
rb_backtrace_length_limit = n; | |
} | |
else { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To install Ruby with this patch: