Skip to content
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

Using another lib with golang #103

Closed
maksimlya opened this issue Feb 11, 2024 · 1 comment
Closed

Using another lib with golang #103

maksimlya opened this issue Feb 11, 2024 · 1 comment

Comments

@maksimlya
Copy link

Hi, first of all, thx for your work, this lib is very usefull for our project, and also I took some inspiration and tried to use a similar approach for my other needs. I've used your project as base/example and follow the methods of using JSI on react native to execute some code on golang.

I made it work, however when I try to run an application that uses both my new lib and this one, it causes app crash.

What is weird:

If I run my app JSI install first, then your encrypt function, the app crashes. If I do otherwise (your module JSI installs, then mine), then it all works fine. Also if I use 'useJSI = false' flag for your app, then it also works fine(probably that because it loads your golib before mine).
I tried to investigate why it happens, and apparently it seems that only 1 'c-shared' go instance can run at same time on a single process.

Now the question, have you got any ideas how to handle that? Sure I can just merge the libs into single shared lib, but it looks like a meh solution since any other addition library that uses cgo will fail too. Thx in advance!

runtime: g 17: unexpected return pc for runtime.cgocallback called from 0x734454d7b4
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E stack: frame={sp:0x72ac09dfb0, fp:0x72ac09dfe0} stack=[0x72ac09c000,0x72ac09e000)
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09deb0: 0x00000072ac09de65 0x0000004000002680
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09dec0: 0x0000000200000003 0x0000004000002680
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09ded0: 0x00000072ac09dea8 0x0000000000000000
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09dee0: 0x00000072f714a6e8 0x00000072ac09df78
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09def0: 0x00000072f6fb6b5c <runtime.cgocallbackg+0x000000000000001c> 0x00000072f70a73b0 <_cgoexp_5c653701e320_OpenPGPBridgeCall+0x0000000000000000>
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09df00: 0x000000400004afe0 0x0000000000000000
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09df10: 0x000000734454d7b4 0x0000000000000000
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09df20: 0x0000000000000000 0x0000000000000000
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09df30: 0x0000000000000000 0x0000000000000000
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09df40: 0x0000000000000000 0x0000000000000000
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09df50: 0x00000072ac09dfe0 0x0000004000002680
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09df60: 0x000000400003c000 0x00000072f70a73b0 <_cgoexp_5c653701e320_OpenPGPBridgeCall+0x0000000000000000>
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09df70: 0x00000072b0ef6900 0x00000072b0ef6808
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09df80: 0x00000072f6fb4ea0 <runtime.cgocallback+0x00000000000000b0> 0x0000000000000000
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09df90: 0x0000000000000000 0x0000000000000000
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09dfa0: 0x0000000000000000 0x0000000000000000
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09dfb0: <0x000000734454d7b4 0x00000072f70a73b0 <_cgoexp_5c653701e320_OpenPGPBridgeCall+0x0000000000000000>
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09dfc0: 0x00000072b0ef6900 0x0000000000000000
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09dfd0: 0x0000000000000000 0x0000000000000000
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09dfe0: >0x0000000000000000 0x0000000000000000
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E 0x00000072ac09dff0: 0x0000000000000000 0x0000000000000000
2024-02-11 23:42:27.730 4723-0 Go com.fastencoderexample E fatal error: unknown caller pc

@jerson
Copy link
Owner

jerson commented Mar 15, 2024

Hi @maksimlya sorry for taking too long to respond but it seems both libraries share the same references I had a solution that involves build a custom go version but probably there are some missing replacement to do there

@jerson jerson closed this as completed May 23, 2024
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

2 participants