Skip to content

node-datachannel Prebuilt Binaries Missing RTTI and Wrong Architecture #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
akhileshthite opened this issue Feb 18, 2025 · 10 comments
Closed

Comments

@akhileshthite
Copy link

Image

We are using Electron with @libp2p/[email protected] which depends on [email protected]. We encountered two major issues:

  1. Linux:
    The native module fails with an undefined RTTI symbol error:
Error: /tmp/.org.chromium.Chromium.XXXX: undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE

This appears to be due to the binary being built with RTTI disabled (likely via -fno-rtti).

  1. macOS (Intel):
    When running the app on an Intel Mac, we see:
mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')

This indicates that the prebuilt binary is compiled for arm64 instead of x86_64.

Workaround

We were able to work around these issues locally by:

  • Patching node-datachannel:
    We modified the build configuration (in cmake/toolchain/ci.cmake) to ensure that the C++ compiler flags include -frtti (enabling RTTI).
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $ENV{COMPILER_FLAGS} -frtti")

https://github.com/ipshipyard/js-node-datachannel/blob/844e1dd9e5467b3fe5d85af23c29751371192d67/cmake/toolchain/ci.cmake#L23

  • Forcing a Rebuild from Source:
    We ran:
npm rebuild node-datachannel --build-from-source

This resulted in a freshly built node_datachannel.node with the correct RTTI support.

Why it's important?

The current approach to work around these problems involves manually patching node-datachannel’s build configuration and explicitly rebuilding the module from source (e.g., using npm rebuild node-datachannel --build-from-source and setting npm_config_arch=x64 on Intel Macs). This process requires custom CI scripts and local workarounds, which is not ideal. Ideally, the prebuilt binaries should be compiled correctly for Electron:

RTTI Enabled: Ensuring that the module is built with RTTI support (i.e. without -fno-rtti).

We observed the same issues when testing with latest @ipshipyard/node-datachannel version ^0.26.4 and @libp2p/webrtc version ^5.1.0.

PR:
p2plabsxyz/peersky-browser#18

@murat-dogan
Copy link
Owner

Hello @akhileshthite,

Thank you for the detailed description.

I remember this error. And it should already be solved in newer versions. Could you please try the new version?
And may I ask why you are using the old version?
#279

I will say we are not using this flag -fno-rtti, and it doesn't seem to be a default value.
Sİnce the problem is solved with a flag, it is mysterious.

We can add the flag (which I think is there by default).
But could you please first try the newer version?

@akhileshthite
Copy link
Author

akhileshthite commented Mar 10, 2025

Hello @akhileshthite,

Thank you for the detailed description.

I remember this error. And it should already be solved in newer versions. Could you please try the new version? And may I ask why you are using the old version? #279

I will say we are not using this flag -fno-rtti, and it doesn't seem to be a default value. Sİnce the problem is solved with a flag, it is mysterious.

We can add the flag (which I think is there by default). But could you please first try the newer version?

Hey @murat-dogan,
Yes, getting same error; I tried @libp2p/[email protected] which is using @ipshipyard/node-datachannel latest version ^0.26.5.

Image

Error:
Image

cc @achingbrain

murat-dogan added a commit that referenced this issue Mar 14, 2025
@murat-dogan
Copy link
Owner

Thanks for the info.

I added and created a PR.
Could you please also check that is OK for you?

Thanks.

@akhileshthite
Copy link
Author

Thanks for the info.

I added and created a PR. Could you please also check that is OK for you?

Thanks.

Thanks!
I’ll apply this as a patch and test it.

@akhileshthite
Copy link
Author

Thanks for the info.
I added and created a PR. Could you please also check that is OK for you?
Thanks.

Thanks! I’ll apply this as a patch and test it.

I tested the CMakeLists.txt patch with https://github.com/ipshipyard/js-node-datachannel node module; left some comments here #343

@achingbrain
Copy link
Contributor

@akhileshthite I think you may have your PR comments still in draft, I don't think there's anything from you on #343

@akhileshthite
Copy link
Author

@akhileshthite I think you may have your PR comments still in draft, I don't think there's anything from you on #343

Sorry, forgot to submit the review.

@murat-dogan
Copy link
Owner

I am a little bit lost here.
The error was:
Error: /tmp/.org.chromium.Chromium.XXXX: undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE

And you said you can solve it with --frtti compiler flag.
The PR adds also this flag; it should resolve it.

The wrong arch is another story.

@akhileshthite
Copy link
Author

I am a little bit lost here. The error was: Error: /tmp/.org.chromium.Chromium.XXXX: undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE

And you said you can solve it with --frtti compiler flag. The PR adds also this flag; it should resolve it.

The wrong arch is another story.

Yes, I will look into that arch issue and resolve it. Let's merge the PR.
Thank you for all your efforts!

murat-dogan added a commit that referenced this issue Apr 11, 2025
@murat-dogan
Copy link
Owner

Hello,
here is the last version
https://github.com/murat-dogan/node-datachannel/releases/tag/v0.27.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants