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

Disconnecting a Controller causes segmentation fault #3

Closed
Shvarpa opened this issue Jun 23, 2020 · 7 comments
Closed

Disconnecting a Controller causes segmentation fault #3

Shvarpa opened this issue Jun 23, 2020 · 7 comments

Comments

@Shvarpa
Copy link

Shvarpa commented Jun 23, 2020

when trying to disconnect a connected controller, the application crashes, for example:

const ViGEmClient = require("vigemclient");
let client = new ViGEmClient();
client.connect();
let controller = client.createX360Controller();
controller.connect();
setTimeout(()=>{
controller.disconnect();
},1000)

causes the terminal to spit out:

npm[16920]: c:\ws\src\node_api.cc:1075: Assertion `(func) != nullptr' failed.
1: 00007FF71140A41F v8::internal::wasm::DisjointAllocationPool::~DisjointAllocationPool+74447
2: 00007FF7113B2F26 v8::base::CPU::has_sse+59718
3: 00007FF7113B32A1 v8::base::CPU::has_sse+60609
4: 00007FF7113DA8BE napi_call_threadsafe_function+30
5: 00007FFEAFF6FB9F x360_notification_callback+159 [D:\Downloads\node-ViGEmClient-master\node-ViGEmClient-master\src\target_x360.cpp]:L9
6: 00007FFEB7BDE988 vigem_target_x360_get_user_index+3816
7: 00007FFEB7BDE823 vigem_target_x360_get_user_index+3459
8: 00007FFEB7BD4D41
9: 00007FFEB7BD46B5
10: 00007FFEB7BD41CA
11: 00007FFEB7BD5563
12: 00007FFEB7BE0A73 vigem_target_x360_get_user_index+12243
13: 00007FFEB7C04F10 vigem_target_x360_get_user_index+160880
14: 00007FFECF037BD4 BaseThreadInitThunk+20
15: 00007FFED018CE51 RtlUserThreadStart+33

image

at first I thought it because controller does not unregister the notification receiver, so i tried the following:

const ViGEmClient = require(".."); // lets say this is done from example folder in repo
const vigemclient = require('../build/Release/vigemclient');
let client = new ViGEmClient();
client.connect();
let controller = client.createX360Controller();
controller.connect();
setTimeout(() => {
vigemclient.vigem_target_x360_unregister_notification(controller._target);
controller.disconnect();
}, 1000);

this causes the application to close with:

error Command failed with exit code 3221225477.

or when run with npx:

/d/Programs/Programming/NodeJS/npx: line 35: 2976 Segmentation fault "$NODE_EXE" "$NPX_CLI_JS" "$@"

I tried putting a delay between removing the notification and disconnecting the controller, and it seems to work, but its not consistent;

const ViGEmClient = require("..");
const vigemclient = require("../build/Release/vigemclient");
let client = new ViGEmClient();
client.connect();
let controller = client.createX360Controller();
controller.connect();
setTimeout(() => {
vigemclient.vigem_target_x360_unregister_notification(controller._target);
setTimeout(() => {
controller.disconnect();
}, 100);
}, 1000);

@jangxx
Copy link
Owner

jangxx commented Jun 23, 2020

Huh, that seems weird. I'll look into it.

@jangxx
Copy link
Owner

jangxx commented Jun 23, 2020

What version of Node are you using? I can't replicate your issue, unfortunately.

@Shvarpa
Copy link
Author

Shvarpa commented Jun 23, 2020

node v14.4.0

@Shvarpa
Copy link
Author

Shvarpa commented Jun 23, 2020

i'll try to replicate the issue on a different pc, just to see if the problem is on my end

@jangxx
Copy link
Owner

jangxx commented Jun 23, 2020

I updated the distributed SDK to the absolutely latest (commited) version and bumped the version to 1.1.1. Can you try the current version from github and tell me if that fixes your problem?

@Shvarpa
Copy link
Author

Shvarpa commented Jun 23, 2020

Seems you've fixed the issue!
controller disconnects fine and the notification callback is removed and inserted properly.
Thanks for the help!!

@Shvarpa Shvarpa closed this as completed Jun 23, 2020
@jangxx
Copy link
Owner

jangxx commented Jun 23, 2020

Great, I will publish version 1.1.1 to npm then.

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