On Wed, Apr 29, 2020 at 4:02 PM <
stijnf...@gmail.com> wrote:
> 1. Am I correct in assuming I have to add any exported values in the SyntheticModuleEvaluationSteps function? I can only call SetSyntheticModuleExport() within that call? This isn't clearly documented everywhere.
It could theoretically also get called later.
> 2. Exporting simple values like integers works fine, but not functions. Here's my code and the corresponding error:
>
> v8::MaybeLocal<v8::Value> ScriptEngine::fillModule(v8::Local<v8::Context> context, v8::Local<v8::Module> module)
> {
> auto isolate = context->GetIsolate();
>
> auto name = v8::String::NewFromUtf8(isolate, "now").ToLocalChecked();
> module->SetSyntheticModuleExport(name, v8::FunctionTemplate::New(isolate, &getNow)->GetFunction(context).ToLocalChecked());
>
> return v8::True(context->GetIsolate());
> }
This code looks unsafe in that the module Local can get dereferenced
before the FunctionTemplate allocation, in which case the resulting
raw address might be invalid after the allocation. Move the allocation
into a separate statement before the call to SetSyntheticModuleExport.
If that doesn't solve your problem please file a bug on the V8 issue
tracker and include code for reproducing it.
--
Georg Neis
Software Engineer
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.