On Thursday, October 12, 2017 at 4:24:44 PM UTC+5, Marja Hölttä wrote:
>
> I don't think it's possible / allowed to use an Isolate from multiple
> threads. The simplest way to do this would be for each thread to have their
> own Isolate (and that's how Chromium does it).
>
Yes, i know that. I've noted Isolate is created on main thread and it's
called on main thread too.
>
> Based on just the error message, I'd guess that you set up the Isolate on
> the main thread, and then invoke the compilation of some script on a
> non-main thread, and that's where the check fails. But that's not the case
> here?
>
I've tried to double check it and it's pretty difficult.
> What's the stack trace when that check fails?
>
Oh, sorry for not publishing it before. This can definitely help:
Stack Trace:
RELADDR FUNCTION
FILE:LINE
000161d5 gin::(anonymous namespace)::PrintStackTrace()
/home/antoine/
chromium/src/gin/v8_platform.cc:55
0000d051 V8_Fatal(char const*, int, char const*, ...)
/home/antoine/
chromium/src/v8/src/base/logging.cc:123
0022eca5 v8::internal::CompilationJob::PrepareJob()
/home/antoine/
chromium/src/v8/src/compiler.cc:86
00235733 v8::internal::(anonymous namespace)::
PrepareAndExecuteUnoptimizedCompileJob(v8::internal::ParseInfo*, v8::
internal::FunctionLiteral*, v8::internal::Isolate*)
/home/antoine/chromium/src/v8/src/compiler.cc:387
0022fe25 v8::internal::(anonymous namespace)::GenerateUnoptimizedCode(v8
::internal::ParseInfo*, v8::internal::Isolate*, std::__ndk1::forward_list<
std::__ndk1::unique_ptr<v8::internal::CompilationJob, std::__ndk1::
default_delete<v8::internal::CompilationJob> >, std::__ndk1::allocator<std::
__ndk1::unique_ptr<v8::internal::CompilationJob, std::__ndk1::default_delete
<v8::internal::CompilationJob> > > >*) /home/
antoine/chromium/src/v8/src/compiler.cc:413
00231f13 v8::internal::(anonymous namespace)::CompileToplevel(v8::
internal::ParseInfo*, v8::internal::Isolate*)
/home/antoine/
chromium/src/v8/src/compiler.cc:786
0023358d v8::internal::Compiler::GetSharedFunctionInfoForScript(v8::
internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::
Object>, int, int, v8::ScriptOriginOptions, v8::internal::Handle<v8::
internal::Object>, v8::internal::Handle<v8::internal::Context>, v8::
Extension*, v8::internal::ScriptData**, v8::ScriptCompiler::CompileOptions,
v8::internal::NativesFlag, v8::internal::Handle<v8::internal::FixedArray>)
/home/antoine/chromium/src/v8/src/compiler.cc:1331
000ff8f1 v8::ScriptCompiler::CompileUnboundInternal(v8::Isolate*, v8::
ScriptCompiler::Source*, v8::ScriptCompiler::CompileOptions)
/home/antoine/
chromium/src/v8/src/api.cc:2314
00100299 v8::ScriptCompiler::Compile(v8::Local<v8::Context>, v8::
ScriptCompiler::Source*, v8::ScriptCompiler::CompileOptions)
/home/
antoine/chromium/src/v8/src/api.cc:2373
00102047 v8::Script::Compile(v8::Local<v8::Context>, v8::Local<v8::String
>, v8::ScriptOrigin*)
/data/app/org.
chromium.chrome-1/lib/arm/libv8.cr.so
>
> Another guess, could it be that we schedule some tasks to be executed in
> the main thread (which is not the isolate's thread) and they then fail when
> executed... but that also doesn't look probable given the code snippet,
> esp. if you're saying that you do create the isolate on the main thread.
>
>
> On Thu, Oct 12, 2017 at 1:15 PM, <[email protected] <javascript:>>
> wrote:
>
>> Hi, Marja.
>>
>> On Thursday, October 12, 2017 at 3:48:49 PM UTC+5, Marja Hölttä wrote:
>>>
>>>
>>>
>>> On Mon, Oct 9, 2017 at 9:11 PM, <[email protected]> wrote:
>>>
>>>> Hi, guys.
>>>>
>>>> I'm having the following assertion failure:
>>>>
>>>> 10-05 11:04:10.654 14154-14154 E/v8: #
>>>> # *Fatal error in
>>>> ../../v8/src/compiler.cc, line 87*
>>>> #
>>>> 10-05 11:04:10.654 14154-14154 E/v8: Debug check failed:
>>>> ThreadId::Current().Equals(compilation_info()->isolate()->thread_id()).
>>>> 10-05 11:04:10.654 14154-14154 E/v8: #
>>>>
>>>> Can anyone explain me what it means?
>>>>
>>>>
>>> The check checks "that we're on the main thread", or, more specifically,
>>> that the current thread is the thread associated to the isolate (which is
>>> the main thread from that V8 instance's point of view). (But based on
>>> below, this is the answer you already knew maybe?)
>>>
>>
>> Yes, this was clear from the very beginning. The question was once thread
>> id is set in Isolate during instantiation can it be changed?
>> The answer seems to be "yes it can be changed after it's set in
>> Isolation", though i did not find actual confirmation.
>> It's difficult to check because it's internals of V8 and i can't just use
>> fprintf() because i'm running it on Android and
>> i'm not enough experienced in V8 and Chromium source code.
>>
>>
>>>
>>>
>>>
>>>
>>>> I'm working on integration of some third-party product into Chromium
>>>> (Android) that is working in Browser process (main).
>>>> The product uses Chromium's V8 and is creating new Isolate using
>>>> IsolateHolder:
>>>>
>>>> // thread
>>>> thread = new base::Thread("MyProductThread");
>>>> thread->Start();
>>>>
>>>> #ifdef V8_USE_EXTERNAL_STARTUP_DATA
>>>> LOG(WARNING) << "MyProduct: loading v8 snapshot & natives ...";
>>>> gin::V8Initializer::LoadV8Snapshot();
>>>> gin::V8Initializer::LoadV8Natives();
>>>> LOG(WARNING) << "MyProduct: loaded v8 snapshot & natives";
>>>> #endif
>>>>
>>>>
>>>> LOG(WARNING) << "MyProduct: initialize isolate holder";
>>>> gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
>>>> gin::IsolateHolder::kStableV8Extras,
>>>> gin::ArrayBufferAllocator::
>>>> SharedInstance());
>>>>
>>>> isolate_holder = new gin::IsolateHolder(
>>>> thread->task_runner(),
>>>> gin::IsolateHolder::AccessMode::kUseLocker);
>>>> isolate_holder->isolate()->Enter();
>>>>
>>>> LOG(WARNING) << "MyProduct: created isolate holder";
>>>>
>>>> // return isolate pointer
>>>> v8::Isolate* isolate = isolate_holder->isolate();
>>>>
>>>> It worked as-is in Aurora project (Qualcomm fork) and i'm completely
>>>> lost why it does not work in pure Chromium.
>>>>
>>>
>>> Is the V8 version the same in both? This check was added pretty recently.
>>>
>>>
>>>> Any suggestion or pointing a direction would be extremely helpful.
>>>>
>>>> Also i've tried to create isolate instance in thread (see the code
>>>> above) in order to put them in the same thread - no luck.
>>>>
>>>
>>>
>>> Not sure how to read your code snippet; does the code below the thread
>>> creation happen inside the thread? Or this is the setup code for the thread
>>> (which is ran in the main thread)?
>>>
>>
>> The code above is invoked on main thread, invocation also comes on main
>> thread (i'm 99.9% sure as i can see thread id in the log) so i expected
>> DCHECK to be successful.
>> Also it makes even more difficult as library that is using that Isolate
>> instance is doing thread synchronization on it's own and probably it
>> affects Chromium's synchronizations too.
>>
>> It was extremely difficult to know what task is being invoked too.
>> I've added v8_platform.cc in order to see when tasks scheduling happens
>> and i can see some tasks are scheduled to be invoked on main thread and
>> some on background.
>>
>>
>>>
>>>
>>> --
>>>
>>>
>>> Google Germany GmbH
>>>
>>> Erika-Mann-Straße 33
>>> <https://maps.google.com/?q=Erika-Mann-Stra%C3%9Fe+33+80636+M%C3%BCnchen&entry=gmail&source=g>
>>>
>>> 80636 München
>>> <https://maps.google.com/?q=Erika-Mann-Stra%C3%9Fe+33+80636+M%C3%BCnchen&entry=gmail&source=g>
>>>
>>> Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
>>>
>>> Registergericht und -nummer: Hamburg, HRB 86891
>>>
>>> Sitz der Gesellschaft: Hamburg
>>>
>>> Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten
>>> haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter,
>>> löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen,
>>> dass die E-Mail an die falsche Person gesendet wurde.
>>>
>>>
>>>
>>> This e-mail is confidential. If you received this communication by
>>> mistake, please don't forward it to anyone else, please erase all copies
>>> and attachments, and please let me know that it has gone to the wrong
>>> person.
>>>
>> --
>> --
>> v8-dev mailing list
>> [email protected] <javascript:>
>> http://groups.google.com/group/v8-dev
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "v8-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>
>
> Google Germany GmbH
>
> Erika-Mann-Straße 33
>
> 80636 München
>
> Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
>
> Registergericht und -nummer: Hamburg, HRB 86891
>
> Sitz der Gesellschaft: Hamburg
>
> Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten
> haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter,
> löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen,
> dass die E-Mail an die falsche Person gesendet wurde.
>
>
>
> This e-mail is confidential. If you received this communication by
> mistake, please don't forward it to anyone else, please erase all copies
> and attachments, and please let me know that it has gone to the wrong
> person.
>
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.