Yeah I don't think this is designed to be thread-safe. For example, we end up calling ProfilerEventsProcessor::AddCurrentStack() which creates a StackFrameIterator from the isolate. To do this it calls isolate->thread_local_top(). The main thread will still be modifying ThreadLocalTop while the 2nd thread tries to read from it e.g. via Isolate::c_entry_fp(top) in StackFrameIterator::Reset().
On Tuesday, April 16, 2019 at 9:24:30 AM UTC+2, Ben Noordhuis wrote: > > On Mon, Apr 15, 2019 at 4:33 PM Bit Cortex <bitc...@gmail.com > <javascript:>> wrote: > > That is, can this method be called from another thread while V8 is > running script code? > > I think the answer is "probably not" but it needs some elaboration. > > Yes, CpuProfiler::CollectSample(Isolate*) acquires a mutex before > collecting the sample. So far so good. > > However, there will be data races when the V8 thread calls other > CpuProfiler methods concurrently (or possibly _any_ V8 methods) > because those methods are _not_ synchronized. Since JS code sometimes > calls into the V8 runtime, I wouldn't want to vouch whether that's > going to work correctly. > > V8's test suite never calls it from a different thread. That's perhaps > a good indicator that it's not supposed to be used that way. > -- -- 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. For more options, visit https://groups.google.com/d/optout.