Related Node.js issue: https://github.com/nodejs/node/issues/45843

The current API for `ExternalStringResource` is such that it heavily pushes 
for RTTI usage: The base class does not offer any API that could be 
overridden to discriminate between different custom subclasses of resources 
(not referring to two-byte vs one-byte, but custom subclasses defined by 
API users like Node.js and addons / embedders).
This means that the only available method to discriminate between 
subclasses would be dynamic casting or the typeid operator.

But, if there are multiple V8 API users running in the same executable, 
like in my case Node.js and a custom Node Addon, then it's possible that 
some of the users have RTTI while others do not. This leads to dynamic 
casting / typeid operator usage on `ExternalStringResource` class being 
susceptible to segmentation faulting.

I ran into this with a custom resource implementation where the 
implementation holds a reference counted string resource inside it. I 
wanted to use a custom API created for the resource class to get a copy of 
the resource counted string wrapper, instead of using the `data()` and 
`length()` APIs to make a manual copy of the string data. Unfortunately, 
any Node.js `ExternString` resources would then segfault if they ended up 
in the API where I was checking for external strings.

I don't really have much to ask here, mainly I guess this is a discussion 
topic. What should be done? Should V8 users be guided to use RTTI, at least 
if they use `ExternalStringResource`? Should V8 add a method to the 
`ExternalStringResource` base class that can be used as a discriminant?

Cheers
-Aapo Alasuutari
 Valmet Automation

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/48ef2554-a77b-4068-98d5-6b7ad73c498fn%40googlegroups.com.

Reply via email to