blinkgc icon indicating copy to clipboard operation
blinkgc copied to clipboard

多线程触发GC时的内存非法访问

Open KookNut opened this issue 3 years ago • 1 comments

非常感谢楼主的分享,剥离GC不易,我在测试过程中,遇到如下的小问题,跟大家分享一下: 在最初的blink initialize时候调用ThreadState::current()->addInterruptor(s_isolateInterruptor);这句代码应该是和V8相关的,我查了一下,在这之前有初始化s_isolateInterruptor的一个操作,但是楼主的源码中没有出现,之前是如下这样的: s_isolateInterruptor = new V8IsolateInterruptor(V8PerIsolateData::mainThreadIsolate()); ThreadState::current()->addInterruptor(s_isolateInterruptor); 这套GC代码在不涉及多线程时候可以稳定运行,但是多线程运行到请求中断时interruptor->requestInterrupt();,因为s_isolateInterruptor未被初始化,所以产生null指针访问,导致程序奔溃。 可以直接屏蔽掉这段代码(ThreadState::current()->addInterruptor(s_isolateInterruptor);),不要在一开始给main thread添加这个null的中断。

KookNut avatar Aug 24 '21 08:08 KookNut

您说的对,这块是v8相关的东西没有整理好

weolar avatar Aug 24 '21 09:08 weolar