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

ne_session_set_event_handler_block prototype #17

Closed
alxtplv opened this issue Mar 4, 2022 · 3 comments
Closed

ne_session_set_event_handler_block prototype #17

alxtplv opened this issue Mar 4, 2022 · 3 comments

Comments

@alxtplv
Copy link

alxtplv commented Mar 4, 2022

Debug version of VPNStatus.app crashes on [ACNEService setupEventCallback]_block_invoke when running on my M1 Apple Silicon. (XCode 13.2.1, MacOS 12.2.1)
M1 release version, and Intel/Rosetta versions work fine, though.

ACDefines.h, line 49
typedef void (^ne_session_set_event_handler_block)(xpc_object_t result);

Perhaps it should be
typedef void (^ne_session_set_event_handler_block)(ne_session_event_t event, void *event_data);

@Timac
Copy link
Owner

Timac commented Mar 4, 2022

Thanks for reporting this weird issue. Could you please run image list in lldb when debugging VPNStatus? At the moment I have no explanation explaining that this issue only occurs for debug builds on M1 machines. Could it be that /usr/lib/system/libsystem_networkextension.dylib is not used on your machine but instead another debug dylib which doesn't know about ne_session_set_event_handler_block?

@alxtplv
Copy link
Author

alxtplv commented Mar 5, 2022

While debugging arm64 version:

(lldb) image list | grep libsystem_networkextension.dylib [ 0] B9F72E76-4B73-3B63-89E0-9D359BFDE954 0x00000001ba6ee000 /usr/lib/system/libsystem_networkextension.dylib

With ne_session_set_event_handler_block changed to
typedef void (^ne_session_set_event_handler_block)(ne_session_event_t event, void *event_data);
and defined typedef int ne_session_event_t; both arm64 VPNStatus builds (debug and release ) work fine on my M1.
X86_64 builds work fine under Rosetta as well.

SCNetworkConnection.c, line 2468
ne_session_set_event_handler(connectionPrivate->ne_session, __SCNetworkConnectionQueue(), ^(ne_session_event_t event, void *event_data) ...

line 2746
ne_session_set_event_handler(new_session, __SCNetworkConnectionQueue(), ^(ne_session_event_t event, void *event_data) ...

Timac added a commit that referenced this issue Mar 5, 2022
…handler_block which could possibly lead to a crash.
@Timac
Copy link
Owner

Timac commented Mar 5, 2022

@alxtplv Thanks a lot for the research and help. It appears that you are absolutely right and I incorrectly reverse-engineered the prototype of ne_session_set_event_handler_block. I modified the code as you suggested.

The fact that the parameters were not used might explain why the release version was not crashing?

@Timac Timac closed this as completed Mar 5, 2022
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