@@ -239,6 +239,11 @@ JL_DLLEXPORT jl_array_t *jl_reshape_array(jl_value_t *atype, jl_array_t *data,
239239 jl_array_t * owner = (jl_array_t * )jl_array_owner (data );
240240 jl_array_data_owner (a ) = (jl_value_t * )owner ;
241241
242+ // For array objects with an owner point (a->flags.how == 3), we would need to
243+ // introspect the object to update the a->data field. To avoid doing that and
244+ // making scan_object much more complex we simply enforce that both owner and
245+ // buffers are always pinned
246+ mmtk_pin_object (owner );
242247 a -> flags .how = 3 ;
243248 a -> data = data -> data ;
244249 a -> flags .isshared = 1 ;
@@ -287,6 +292,11 @@ JL_DLLEXPORT jl_array_t *jl_string_to_array(jl_value_t *str)
287292 a -> flags .ptrarray = 0 ;
288293 a -> flags .hasptr = 0 ;
289294 jl_array_data_owner (a ) = str ;
295+ // For array objects with an owner point (a->flags.how == 3), we would need to
296+ // introspect the object to update the a->data field. To avoid doing that and
297+ // making scan_object much more complex we simply enforce that both owner and
298+ // buffers are always pinned
299+ mmtk_pin_object (str );
290300 a -> flags .how = 3 ;
291301 a -> flags .isshared = 1 ;
292302 size_t l = jl_string_len (str );
@@ -683,6 +693,11 @@ static int NOINLINE array_resize_buffer(jl_array_t *a, size_t newlen)
683693 else {
684694 s = jl_gc_realloc_string (jl_array_data_owner (a ), nbytes - (elsz == 1 ));
685695 }
696+ // For array objects with an owner point (a->flags.how == 3), we would need to
697+ // introspect the object to update the a->data field. To avoid doing that and
698+ // making scan_object much more complex we simply enforce that both owner and
699+ // buffers are always pinned
700+ mmtk_pin_object (s );
686701 jl_array_data_owner (a ) = s ;
687702 jl_gc_wb (a , s );
688703 a -> data = jl_string_data (s );
0 commit comments