On Thu, Feb 18, 2021 at 6:36 PM pat m <patmccl...@gmail.com> wrote: > > Hello, > > I am working on a Node.js module that creates a CodeEventHandler > (https://v8docs.nodesource.com/node-14.15/d2/d08/classv8_1_1_code_event_handler.html). > I've seen that it's Handle method can be called from outside the main > isolate thread, i.e. for parallel garbage collection: > > #3 0x00007f393a5fb0f3 in > codeevents::FnInspectCodeEventHandler::Handle(v8::CodeEvent*) () from > /home/ec2-user/module.node > #4 0x0000000000e43705 in > v8::internal::ExternalCodeEventListener::CodeMoveEvent(v8::internal::AbstractCode, > v8::internal::AbstractCode) () > #5 0x0000000000d5707a in > v8::internal::ProfilingMigrationObserver::Move(v8::internal::AllocationSpace, > v8::internal::HeapObject, v8::internal::HeapObject, int) () > #6 0x0000000000d6d41b in void > v8::internal::EvacuateVisitorBase::RawMigrateObject<(v8::internal::EvacuateVisitorBase::MigrationMode)1>(v8::internal::EvacuateVisitorBase*, > v8::internal::HeapObject, v8::internal::HeapObject, int, > v8::internal::AllocationSpace) () > #7 0x0000000000d706df in > v8::internal::FullEvacuator::RawEvacuatePage(v8::internal::MemoryChunk*, > long*) () > #8 0x0000000000d5d17f in > v8::internal::Evacuator::EvacuatePage(v8::internal::MemoryChunk*) () > #9 0x0000000000d5d67f in > v8::internal::PageEvacuationTask::RunInParallel(v8::internal::ItemParallelJob::Task::Runner) > () > #10 0x0000000000d4f8c5 in v8::internal::ItemParallelJob::Task::RunInternal() > () > #11 0x0000000000c6c9eb in non-virtual thunk to > v8::internal::CancelableTask::Run() () > #12 0x0000000000a71405 in node::(anonymous > namespace)::PlatformWorkerThread(void*) () > #13 0x00007f3bd38d440b in start_thread () from /lib64/libpthread.so.0 > #14 0x00007f3bd360ef9f in clone () from /lib64/libc.so.6 > > Is it safe to access the String values returned by GetFunctionName and > GetScriptName in this context (i.e. using String.Write)? Any method to > access the underlying characters requires passing the isolate as a parameter, > and all of the docs I can find say it's not safe to use the isolate without > entering it via Locker. However that isn't viable in this case as the > Node.js main thread locks the isolate on startup, so trying to get a lock on > the isolate simply deadlocks the thread. > > thanks > pat
In the case of a CODE_MOVED event, event.script doesn't point to anything. That field is only valid (and then only sometimes) for CODE_ADDED events. I noticed a small bug - V8 doesn't clear unused JitCodeEvent fields when it emits a CODE_MOVED event - that might be why you get random crashes instead of nullptr segfaults. diff --git a/src/logging/log.cc b/src/logging/log.cc index 7738cab831..94497f6502 100644 --- a/src/logging/log.cc +++ b/src/logging/log.cc @@ -751,6 +751,7 @@ void JitLogger::CodeMoveEvent(AbstractCode from, AbstractCode to) { base::MutexGuard guard(&logger_mutex_); JitCodeEvent event; + memset(static_cast<void*>(&event), 0, sizeof(event)); event.type = JitCodeEvent::CODE_MOVED; event.code_type = from.IsCode() ? JitCodeEvent::JIT_CODE : JitCodeEvent::BYTE_CODE; -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/CAHQurc-%3D0b2ye9uZsoZcuE0YXEDLcOM65LH4n74psx%3DYHfe45w%40mail.gmail.com.