Skip to content

Add link3dsDisconnectFromHost()#602

Open
ZeroSkill1 wants to merge 1 commit intodevkitPro:masterfrom
ZeroSkill1:3dslink-exit-fix
Open

Add link3dsDisconnectFromHost()#602
ZeroSkill1 wants to merge 1 commit intodevkitPro:masterfrom
ZeroSkill1:3dslink-exit-fix

Conversation

@ZeroSkill1
Copy link
Copy Markdown
Contributor

This fixes a potential crash when linking stdout/stderr to 3dslink output.

Even when closing the socket as instructed in the docstring, a crash can occur.

In socExit, the soc device is removed from devoptab_list, which invalidates the device in the file descriptor for the socket/stderr/stdout. During an exit routine, newlib calls into cleanup_stdio, which closes the std streams.
This creates the case where handles[STD_OUT] and handles[STD_ERR] are valid but the corresponding devoptab entry is no longer alive. Hence, close() on stdio/err causes a segfault.

The solution is to close both stdout and stderr along with the socket when disconnecting from the 3dslink host. For convenience, this has been placed into a wrapper, link3dsDisconnectFromHost.

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

Successfully merging this pull request may close these issues.

1 participant