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: shouldn't use stack-pointer to avoid stackgrow problem #515

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AsterDY
Copy link
Collaborator

@AsterDY AsterDY commented Aug 25, 2023

Reason

Since this place reference a pointer from the stack, once stackgrow happens after entering encoderTypedPointer, the pointer may be invalid and introduce potential NPE problem.

Fix

Malloc a new(unsafe.Pointer) obj on heap and store its pointer onto stack. Then write the value pointer vp onto the obj

Affect

Will introduce more malloc when encoding large structure. For our test sample Twitter, it will cause 6%~8% downgrades of performance

@codecov-commenter
Copy link

codecov-commenter commented Aug 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8c71eb0) 78.57% compared to head (90bacc6) 78.60%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #515      +/-   ##
==========================================
+ Coverage   78.57%   78.60%   +0.03%     
==========================================
  Files          69       69              
  Lines       10714    10732      +18     
==========================================
+ Hits         8418     8436      +18     
  Misses       1930     1930              
  Partials      366      366              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AsterDY AsterDY marked this pull request as draft September 5, 2023 05:31
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.

None yet

2 participants