Respect RUBY_CRASH_REPORT path when RUBY_ASSERT() fails
Previously, it always used stderr. Slight shuffle of the first line of the crash due to reusing code from rb_bug(): ```diff -Assertion Failed: /ruby/object.c:649:rb_obj_itself:false +/ruby/object.c:649: Assertion Failed: rb_obj_itself:false ``` Tested locally to confirm that it writes to the file given with RUBY_CRASH_REPORT. Follow-up for [Feature #19790].
This commit is contained in:
parent
3f7c72cd33
commit
fca07d73e3
Notes:
git
2024-11-07 14:35:38 +00:00
Merged: https://github.com/ruby/ruby/pull/12019 Merged-By: XrXr
32
error.c
32
error.c
@ -1173,23 +1173,27 @@ void
|
|||||||
rb_assert_failure_detail(const char *file, int line, const char *name, const char *expr,
|
rb_assert_failure_detail(const char *file, int line, const char *name, const char *expr,
|
||||||
const char *fmt, ...)
|
const char *fmt, ...)
|
||||||
{
|
{
|
||||||
FILE *out = stderr;
|
rb_pid_t pid = -1;
|
||||||
fprintf(out, "Assertion Failed: %s:%d:", file, line);
|
FILE *out = bug_report_file(file, line, &pid);
|
||||||
if (name) fprintf(out, "%s:", name);
|
if (out) {
|
||||||
fputs(expr, out);
|
fputs("Assertion Failed: ", out);
|
||||||
|
if (name) fprintf(out, "%s:", name);
|
||||||
|
fputs(expr, out);
|
||||||
|
|
||||||
if (fmt && *fmt) {
|
if (fmt && *fmt) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
fputs(": ", out);
|
fputs(": ", out);
|
||||||
vfprintf(out, fmt, args);
|
vfprintf(out, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
}
|
||||||
|
fprintf(out, "\n%s\n\n", rb_dynamic_description);
|
||||||
|
|
||||||
|
preface_dump(out);
|
||||||
|
rb_vm_bugreport(NULL, out);
|
||||||
|
bug_report_end(out, pid);
|
||||||
}
|
}
|
||||||
fprintf(out, "\n%s\n\n", rb_dynamic_description);
|
|
||||||
|
|
||||||
preface_dump(out);
|
|
||||||
rb_vm_bugreport(NULL, out);
|
|
||||||
bug_report_end(out, -1);
|
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user