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: incorrect usage of const ref shared ptr in container class #1010

Merged
merged 1 commit into from
Jan 1, 2025

Conversation

nekiro
Copy link
Collaborator

@nekiro nekiro commented Jan 1, 2025

Description

Fix an invalid (unsafe) usage of const reference to shared_ptr in container class.

Behavior

Actual

Crashes with stacktrace pointing to LuaInterface::pushObject. This happens, because the const ref is unsafe there.
After you remove the shared pointer from container it may get destructured (shared_ptr is a normal instance of a class).
This happens in this case, we need a copy to keep the pointer alive here.
I haven't had luck with reproducing this in Release mode, likely, because compiler somehow optimizes the code.

Stacktrace:
image

Expected

I reproduced this crash several times by running around and spamming ultimate healing runes with open backpacks via action bar.

Fixes

not a reported issue

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • Server Version:
  • Client:
  • Operating System:

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I checked the PR checks reports
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Copy link

sonarqubecloud bot commented Jan 1, 2025

@mehah mehah changed the title Fix incorrect usage of const ref shared ptr in container class fix: incorrect usage of const ref shared ptr in container class Jan 1, 2025
@mehah mehah merged commit 093edcc into main Jan 1, 2025
12 checks passed
@mehah mehah deleted the fix-crash-in-container branch January 1, 2025 23:40
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