Ah, I think I found the issue (right before I was to file the issue). There are two varieties of *SetSyntheticModuleExport()*, though only one of them is mentioned in the docs (even the latest). Looking at the v8 headers, the one taking two arguments is soon to be deprecated for one taking an Isolate*.*
Using the second one gives better error reporting (in my case I forgot the mention the function name in *CreateSyntheticModule()*). On Wednesday, 29 April 2020 16:40:03 UTC+2, [email protected] wrote: > > Thanks for you reply, Georg. > > How exactly can the *module* local get dereferenced before the call? I > reckon you mean the FunctionTemplate local? > > In any case, moving the FunctionTemplate creation to a separate line > before that doesn't solve the problem. > I'll file a report with the issue tracker, then :) > > On Wednesday, 29 April 2020 16:19:05 UTC+2, Georg Neis wrote: >> >> On Wed, Apr 29, 2020 at 4:02 PM <[email protected]> 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. >> > -- -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/5c778872-5415-4c93-b209-9d7878a9db2c%40googlegroups.com.
