fix: shouldn't use stack-pointer to avoid stackgrow problem
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 Report
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
8c71eb0) 78.57% compared to head (90bacc6) 78.60%.
:exclamation: 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
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.