-
Notifications
You must be signed in to change notification settings - Fork 817
Closed
Description
Following causes a crash:
mrb_state * mrb = mrb_open();
mrb_load_string( mrb, "__FILE__" );
enable_debug prints:
mrb_debug_info_append_file: assertion "irep->filename" failed
The culprit is the strlen check here:
https://github.com/mruby/mruby/blob/master/src/debug.c#L157
It is my understanding that strlen( NULL ) is undefined behaviour. I expect there are platforms that will return 0 for this case and thus silently continue.
Removing the assert and changing 157 to check for NULL fixes the crash:
// mrb_assert(irep->filename);
fn_len = irep->filename ? strlen(irep->filename) : 0;
I don't consider this a solution as it results in __FILE__ printing as (null), rather than anything meaningful.
In the case of __FILE__ without a file-name, what is the expected output? Is there a mechanism for defining the value for __FILE__?
Metadata
Metadata
Assignees
Labels
No labels