Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Missing js::SharedArrayRawBufferRefs::~SharedArrayRawBufferRefs symbol in spidermonkey 68

42 views
Skip to first unread message

bell...@gmail.com

unread,
Jun 4, 2020, 3:51:17 AM6/4/20
to
Hi,

I am trying to use JSAutoStructuredCloneBuffer from js/StructuredClone in an application that uses spidermonkey 68 as its scripting engine. When I try to link the application the linker complains about missing SharedArrayRawBufferRefs symbol.

/usr/include/mozjs-68/js/StructuredClone.h:433: undefined reference to `js::SharedArrayRawBufferRefs::~SharedArrayRawBufferRefs()'

I am using my system mozjs-68 library (I am on debian bullseye). However, if I try to compile it from source using the information in https://github.com/mozilla-spidermonkey/spidermonkey-embedding-examples/blob/esr68/docs/Building%20SpiderMonkey.md still, the destructor symbol is not exported by the compiled mozjs-68 library.

objdump -T libmozjs-68.so | c++filt | grep SharedArrayRawBufferRefs
(none)

as comparison:

objdump -T libmozjs-68.so | c++filt | grep JSAutoStructuredCloneBuffer
00000000005838b0 g DF .text 0000000000000082 mozjs_68 JSAutoStructuredCloneBuffer::JSAutoStructuredCloneBuffer(JSAutoStructuredCloneBuffer&&)
00000000005837c0 g DF .text 000000000000007c mozjs_68 JSAutoStructuredCloneBuffer::write(JSContext*, JS::Handle<JS::Value>, JSStructuredCloneCallbacks const*, void*)
0000000000583840 g DF .text 0000000000000070 mozjs_68 JSAutoStructuredCloneBuffer::read(JSContext*, JS::MutableHandle<JS::Value>, JSStructuredCloneCallbacks const*, void*)
0000000000583e60 g DF .text 0000000000000314 mozjs_68 JSAutoStructuredCloneBuffer::adopt(JSStructuredCloneData&&, unsigned int, JSStructuredCloneCallbacks const*, void*)
00000000005838b0 g DF .text 0000000000000082 mozjs_68 JSAutoStructuredCloneBuffer::JSAutoStructuredCloneBuffer(JSAutoStructuredCloneBuffer&&)
0000000000583c70 g DF .text 00000000000000bc mozjs_68 JSAutoStructuredCloneBuffer::operator=(JSAutoStructuredCloneBuffer&&)
0000000000583940 g DF .text 0000000000000322 mozjs_68 JSAutoStructuredCloneBuffer::steal(JSStructuredCloneData*, unsigned int*, JSStructuredCloneCallbacks const**, void**)
0000000000584180 g DF .text 000000000000006e mozjs_68 JSAutoStructuredCloneBuffer::write(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::CloneDataPolicy, JSStructuredCloneCallbacks const*, void*)
0000000000583d30 g DF .text 0000000000000129 mozjs_68 JSAutoStructuredCloneBuffer::clear()

Am I missing something? All the other symbols I use (Context creation, value r/w, GC management etc etc.) are correctly found, just SharedArrayRawBufferRefs destructor is not found. I use JSAutoStructuredCloneBuffer to move data between contexts. Is it the right way to do it? thanks!

bell...@gmail.com

unread,
Jun 6, 2020, 5:09:14 PM6/6/20
to
BTW, I would be satisfied just to understand how to move data between contexts. Using stringify it's too limiting (missing Map, Regex, etc..).

Kannan Vijayan

unread,
Jun 9, 2020, 5:21:08 PM6/9/20
to bell...@gmail.com, dev-tech-...@lists.mozilla.org
Hi,

Are you sure you're compiling with the correct headers for your library? I
took a look around, and at least by the current codebase that export list
seems reasonable. The definition of the destructor is inlined in the
header, and is a call to `clear`, which is exported in your list.

https://searchfox.org/mozilla-central/rev/fac90408bcf52ca88a3dcd2ef30a379b68ab24e2/js/public/StructuredClone.h#643

On Sat, Jun 6, 2020 at 5:10 PM <bell...@gmail.com> wrote:

> BTW, I would be satisfied just to understand how to move data between
> contexts. Using stringify it's too limiting (missing Map, Regex, etc..).
> _______________________________________________
> dev-tech-js-engine mailing list
> dev-tech-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
>

Steve Fink

unread,
Jun 9, 2020, 6:12:56 PM6/9/20
to bell...@gmail.com, dev-tech-...@lists.mozilla.org
On 6/6/20 2:09 PM, bell...@gmail.com wrote:
> BTW, I would be satisfied just to understand how to move data between contexts. Using stringify it's too limiting (missing Map, Regex, etc..).

Just to be sure I understand what you mean by "move data between
contexts": do you have multiple threads, each with their own runtime?
These days, there's only one context and runtime per thread, so moving
data between contexts is rare.

Structured clone preserves more information than stringify, but it is
still very lossy -- it preserves neither an object's identity nor its
prototype, for example. (Its semantics are defined in the HTML spec:
https://html.spec.whatwg.org/multipage/structured-data.html#safe-passing-of-structured-data
). I don't think we have any way to share data between runtimes that
isn't some form of lossy serialization/deserialization.

js::SharedArrayRawBufferRefs is not marked JS_PUBLIC_API. It is a member
of JSStructuredCloneData, which *is* marked JS_PUBLIC_API. It looks like
an omission to me. I filed
https://bugzilla.mozilla.org/show_bug.cgi?id=1644600

bell...@gmail.com

unread,
Jun 10, 2020, 3:24:07 AM6/10/20
to
On Wednesday, June 10, 2020 at 12:12:56 AM UTC+2, Steve Fink wrote:
> On 6/6/20 2:09 PM, bell...@gmail.com wrote:
> > BTW, I would be satisfied just to understand how to move data between contexts. Using stringify it's too limiting (missing Map, Regex, etc..).
>
> Just to be sure I understand what you mean by "move data between
> contexts": do you have multiple threads, each with their own runtime?
> These days, there's only one context and runtime per thread, so moving
> data between contexts is rare.

Yes, that's the case. The application I am porting to SM 68 ( 0ad https://trac.wildfiregames.com/) uses multiple Runtimes/Threads in distinct threads.

> Structured clone preserves more information than stringify, but it is
> still very lossy -- it preserves neither an object's identity nor its
> prototype, for example. (Its semantics are defined in the HTML spec:
> https://html.spec.whatwg.org/multipage/structured-data.html#safe-passing-of-structured-data
> ). I don't think we have any way to share data between runtimes that
> isn't some form of lossy serialization/deserialization.
>
> js::SharedArrayRawBufferRefs is not marked JS_PUBLIC_API. It is a member
> of JSStructuredCloneData, which *is* marked JS_PUBLIC_API. It looks like
> an omission to me. I filed
> https://bugzilla.mozilla.org/show_bug.cgi?id=1644600

Yes, I am aware that using StructuredClone might still produce a loss of information. However it is sufficient for me :)

Thanks for opening the ticket!

bell...@gmail.com

unread,
Jun 10, 2020, 3:27:16 AM6/10/20
to
Hi!

I think so. The headers are provided by the mozjs development package of Debian 11 and I am using the mozjs pkg-config script to fetch the required informations.
0 new messages