зеркало из https://github.com/github/ruby.git
[Prism] Don't change file after setting it.
This causes the Iseq file names to be wrong, which is affecting Tracepoint events in certain cases. because we're taking a pointer to the string and using it in `pm_string_mapped_pointer` we also need to `RB_GC_GUARD` the relevant Ruby object to ensure it's not moved or swept before the parser has been free'd.
This commit is contained in:
Родитель
4592fdc545
Коммит
d054904cad
7
iseq.c
7
iseq.c
|
@ -1475,12 +1475,12 @@ iseqw_s_compile_prism(int argc, VALUE *argv, VALUE self)
|
|||
|
||||
pm_parser_t parser;
|
||||
|
||||
VALUE file_path = Qnil;
|
||||
pm_string_t input;
|
||||
if (RB_TYPE_P(src, T_FILE)) {
|
||||
FilePathValue(src);
|
||||
file = rb_fstring(src); /* rb_io_t->pathv gets frozen anyways */
|
||||
file_path = rb_io_path(src); /* rb_io_t->pathv gets frozen anyways */
|
||||
|
||||
pm_string_mapped_init(&input, RSTRING_PTR(file));
|
||||
pm_string_mapped_init(&input, RSTRING_PTR(file_path));
|
||||
}
|
||||
else {
|
||||
Check_Type(src, T_STRING);
|
||||
|
@ -1493,6 +1493,7 @@ iseqw_s_compile_prism(int argc, VALUE *argv, VALUE self)
|
|||
|
||||
rb_iseq_t *iseq = iseq_alloc();
|
||||
iseqw_s_compile_prism_compile(&parser, opt, iseq, file, path, start_line);
|
||||
RB_GC_GUARD(file_path);
|
||||
pm_parser_free(&parser);
|
||||
pm_options_free(&options);
|
||||
pm_string_free(&input);
|
||||
|
|
Загрузка…
Ссылка в новой задаче