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

Socket: Fix a nullptr dereference when operations are pending #12462

Merged
merged 1 commit into from Dec 25, 2023

Conversation

sepalani
Copy link
Contributor

This PR fixes the crash mentioned in https://dolp.in/i13442.

I suppose it's introduced in #11767. Since the instance was moved to the kernel, it's destroyed when the kernel is. When the socket manager is destroyed so are its sockets which will abort pending operations. Pending operations relied on GetIOS() to abort them. However, this function will return nullptr on force shutdown because s_ios.reset() is called. So it wasn't able to call member functions of the IOS instance being destructed and was dereferencing nullptr instead.

I created a simple test case to reproduce the issue which is accepting a socket connection. You just need to run it (and not connect to it), then force shutdown the homebrew by pressing the stop button twice on the GUI which will crash Dolphin.
net_accept.zip

Ready to be reviewed & merged.

Copy link
Contributor

@iwubcode iwubcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Untested

@@ -256,7 +256,7 @@ class WiiSockMan
s64 timeout = 0;
};

WiiSockMan();
WiiSockMan(EmulationKernel& m_ios);
Copy link
Member

@lioncash lioncash Dec 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
WiiSockMan(EmulationKernel& m_ios);
explicit WiiSockMan(EmulationKernel& ios);

@AdmiralCurtiss AdmiralCurtiss merged commit 3cb5d34 into dolphin-emu:master Dec 25, 2023
11 checks passed
@sepalani sepalani deleted the net-force-shutdown branch December 25, 2023 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants