diff --git a/src/factory.cc b/src/factory.cc index 98361d1716..99f80ed37b 100644 --- a/src/factory.cc +++ b/src/factory.cc @@ -2239,14 +2239,19 @@ Handle Factory::NewDebugInfo(Handle shared) { Handle::cast(NewStruct(DEBUG_INFO_TYPE)); debug_info->set_shared(*shared); if (shared->HasBytecodeArray()) { - // Create a copy for debugging. - Handle original(shared->bytecode_array(), isolate()); - Handle copy = CopyBytecodeArray(original); - debug_info->set_abstract_code(AbstractCode::cast(*copy)); + // We need to create a copy, but delay since this may cause heap + // verification. + debug_info->set_abstract_code(AbstractCode::cast(shared->bytecode_array())); } else { debug_info->set_abstract_code(AbstractCode::cast(shared->code())); } debug_info->set_break_points(*break_points); + if (shared->HasBytecodeArray()) { + // Create a copy for debugging. + Handle original(shared->bytecode_array()); + Handle copy = CopyBytecodeArray(original); + debug_info->set_abstract_code(AbstractCode::cast(*copy)); + } // Link debug info to function. shared->set_debug_info(*debug_info);