-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix illegal GC-violating call to
jl_subtype
in static_show
Implement custom iterative check via `->super`
- Loading branch information
Showing
1 changed file
with
14 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -641,6 +641,19 @@ static size_t jl_static_show_x_sym_escaped(JL_STREAM *out, jl_sym_t *name) JL_NO | |
return n; | ||
} | ||
|
||
// `jl_static_show()` cannot call `jl_subtype()`, for the GC reasons | ||
// explained in the comment on `jl_static_show_x_()`, below. | ||
// This function checks if `vt <: Function` without triggering GC. | ||
static int jl_static_is_function_(jl_datatype_t *vt) { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
while (vt != jl_any_type) { | ||
if (vt == jl_function_type) { | ||
return 1; | ||
} | ||
vt = vt->super; | ||
} | ||
return 0; | ||
} | ||
|
||
// `v` might be pointing to a field inlined in a structure therefore | ||
// `jl_typeof(v)` may not be the same with `vt` and only `vt` should be | ||
// used to determine the type of the value. | ||
|
@@ -999,7 +1012,7 @@ static size_t jl_static_show_x_(JL_STREAM *out, jl_value_t *v, jl_datatype_t *vt | |
n += jl_static_show_x(out, *(jl_value_t**)v, depth); | ||
n += jl_printf(out, ")"); | ||
} | ||
else if (jl_function_type && jl_subtype(vt, (jl_value_t*)jl_function_type)) { | ||
else if (jl_function_type && jl_static_is_function_(vt)) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
NHDaly
Author
Member
|
||
// v is function instance (an instance of a Function type). | ||
jl_datatype_t *dv = (jl_datatype_t*)vt; | ||
jl_sym_t *sym = dv->name->mt->name; | ||
|
JL_NOTSAFEPOINT