Hi Camillo, Thank you for the quick response. I failed to find any public API that could meet my need, so I had to use the internal one.
The requirement I got is: To tell whether a function is a user defined JS function or not. However, I failed to find any API in v8::Function could tell that. The only possible one is ToString() which usually returns [native code]. But, ToString() can be easily polyfilled to avoid the detection. I had to turn to v8::internal for the solution and found SharedFunctionInfo::IsUserJavaScript() is a reliable source. When I was testing v9.0, this API core dumped and I had to use that workaround. Hope this makes sense. Thank you, Sam On Mon, May 17, 2021 at 6:35 PM Camillo Bruni <[email protected]> wrote: > Hi Sam, > > It seems like you're using V8 internal parts that are not exposed in the v8 > api <https://source.chromium.org/search?q=v8.h>. > Do you have a minimal example using the public API that crashes? > > cheers, > Camillo > > On Mon, 17 May 2021 at 11:02, Sam Cao <[email protected]> wrote: > >> Hi There, >> >> I'm working on embedding V8 (v9.0.257) in a C++ project and found >> SharedFunctionInfo::IsUserJavaScript() coredump on native function. >> >> *Symptom* >> Get a native function (e.g. Array.push) as x, then call >> x.shared().IsUserJavaScript(), a coredump will occur on v9.0.257. >> >> I did the same on v8.4, it returned false. >> >> *Possible Root Cause* >> In v9.0.257: SharedFunctionInfo::IsUserJavaScript() => >> SharedFunctionInfo::script() >> => script_or_debug_info(kAcquireLoad), but in v8.4 script_or_debug_info() >> is called. >> >> I suspect the acquire and release feature introduced in v9.0 is not well >> taken care of by native function. >> >> *Workaround* >> Currently, my workaround is as following. >> auto v8InternalShared = v8InternalFunction.shared(); >> if (v8InternalShared.native()) { >> // native >> } >> else if (v8InternalShared.IsApiFunction()) { >> // api >> } >> else if (v8InternalShared.IsUserJavaScript()) { >> // user >> } >> My expectation is I don't need to call the first 2 API to prevent >> coredump, but call IsUserJavaScript() directly. >> >> *Summary* >> I just browsed the master branch and found the related code was identical >> to v9.0.257. I'm quite new to this group, please forgive me for not being >> professional here. May I know if someone will check this out? >> >> Thank you, >> Sam >> >> -- >> -- >> 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/ebb76291-b395-4b61-a0de-1b19a39514f4n%40googlegroups.com >> <https://groups.google.com/d/msgid/v8-dev/ebb76291-b395-4b61-a0de-1b19a39514f4n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > Camillo Bruni | Software Engineer, V8 | Google Germany GmbH | Erika-Mann > Str. 33, 80636 München > > Registergericht und -nummer: Hamburg, HRB 86891 | Sitz der Gesellschaft: > Hamburg | Geschäftsführer: Paul Manicle, Halimah DeLaine Prado > > Diese E-Mail ist vertraulich. Falls Ssie 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 a topic in the > Google Groups "v8-dev" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/v8-dev/6dwXnt57eTk/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/v8-dev/CAOeS1i-MEDvA%2BgSDtVea7ufKP1UP70Ci5osEFfuiRX-TYJ_HAg%40mail.gmail.com > <https://groups.google.com/d/msgid/v8-dev/CAOeS1i-MEDvA%2BgSDtVea7ufKP1UP70Ci5osEFfuiRX-TYJ_HAg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- -- caocao -- -- 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/CADa8QzHAGJERBo7Jyo2RpmzKo_J6HopXDHB7pf4D55SfRO5wmw%40mail.gmail.com.
