bytedance / sonic

A blazingly fast JSON serializing & deserializing library
Apache License 2.0
6.54k stars 322 forks source link

fix: invalid pcsp in x86_64 #644

Closed liuq19 closed 3 weeks ago

liuq19 commented 1 month ago
  1. calculate the correct PCSP table as Golang
  2. enhanced the PCSP tests through sigtrap handler

Some details: For calculate PCSP:

  1. we should concern the sp relative instructions: call, ret, subq imm, %rsp, addq imm, %rsp, leaq imm(%rbp), %rsp
  2. we should disable the instruction andq imm, %rsp, because of the lack of an exact delta

For test PCSP:

  1. we register the mock binary (mock with 0xcc instruction) as a mock function, and each 0xcc will cause trap
  2. we linked the testSigtrap function in golang runtime to test backtrace in each trap instruction

Related PR in asm2asm tool is https://github.com/cloudwego/asm2asm/pull/5

codecov-commenter commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 71.21%. Comparing base (99f5b35) to head (2a49e8a). Report is 14 commits behind head on main.

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

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #644 +/- ## ========================================== - Coverage 77.56% 71.21% -6.35% ========================================== Files 83 130 +47 Lines 11542 8363 -3179 ========================================== - Hits 8952 5956 -2996 + Misses 2192 2084 -108 + Partials 398 323 -75 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.