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

Fix deadlock inside BASS library finalization. #223

Merged
merged 2 commits into from
Oct 5, 2024

Conversation

MiranDMC
Copy link
Collaborator

No description provided.

@MiranDMC MiranDMC requested a review from x87 September 30, 2024 08:00
@@ -52,7 +53,7 @@ namespace CLEO
if (initialized)
{
TRACE("Freeing BASS library");
BASS_Free();
std::thread(BASS_Free);
Copy link

Choose a reason for hiding this comment

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

why is there a deadlock?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The library internally waits to some (COM?) objects to be finalized. BASS author says free can not be called in dll main. I tried to do it from some other callback like on game closing, but with same results. Other author suggestion is not to call free at all and let it be released automatically, but that makes game crashing (I guess due all ModLoader hacks).

Calling it from another thread works. It is visible in log that CLEO proceeded with other cleanup steps, game aslo closes without problems.

Copy link

Choose a reason for hiding this comment

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

Interesting. I would also remove free and let OS handle the unloading.

Is the crash reproducible 100%? Does it depend on other plugins installed in game?

Copy link
Collaborator Author

@MiranDMC MiranDMC Sep 30, 2024

Choose a reason for hiding this comment

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

Seems like all you need is ModLoader. BASS_Free changing has some results in web search.

Copy link

Choose a reason for hiding this comment

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

Why it wasn't an issue in CLEO4?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have no idea. ModLoader is thin ice. In CLEO4 Bass was managed by core.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm seems to be working without calling free at all. I have no idea why game was crashing for me when testing it previously.

@MiranDMC MiranDMC requested a review from x87 October 5, 2024 10:54
@MiranDMC MiranDMC merged commit a669995 into master Oct 5, 2024
1 check passed
@MiranDMC MiranDMC deleted the Fix_deadlock_inside_BASS_library_finalization branch October 5, 2024 11:56
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.

2 participants