This is an archive of the discontinued LLVM Phabricator instance.

[FuzzMutate] Skip EHPad during mutation and avoid replacing callee with pointer when sinking
ClosedPublic

Authored by HazyFish on Apr 20 2023, 3:52 PM.

Details

Summary

This patch addresses 2 problems:

  • In ShuffleBlockStrategy, when BB is an EHPad, BB.getFirstInsertionPt() will return BB.end(), which cannot be dereferenced and will cause crash in following loop.
  • In isCompatibleReplacement, a call instruction's callee might be replaced by a pointer, causing 2 subproblems:
    • we cannot guarantee that the pointer is a function pointer (even if it is, we cannot guarantee it matches the signature).
    • after such a replacement, getCalledFunction will from then on return nullptr (since it's indirect call) which causes Segmentation Fault in the lines below.

This patch fixes the first problem by checking if a block to be mutated is an EHPad in base class IRMutationStrategy and skipping mutating it if so.

This patch fixes the second problem by avoiding replacing callee with pointer and adding a null check for indirect calls.

Diff Detail

Event Timeline

HazyFish created this revision.Apr 20 2023, 3:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2023, 3:52 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
HazyFish requested review of this revision.Apr 20 2023, 3:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2023, 3:52 PM
Peter added inline comments.Apr 20 2023, 5:45 PM
llvm/unittests/FuzzMutate/StrategiesTest.cpp
659

Can you run this module against all strategies?

HazyFish updated this revision to Diff 516988.Apr 25 2023, 5:08 PM
HazyFish retitled this revision from [FuzzMutate] Skip EHPad for ShuffleBlockStrategy to avoid crash to [FuzzMutate] Skip EHPad to avoid crash during mutation.
HazyFish edited the summary of this revision. (Show Details)
HazyFish added a reviewer: oakrc.
  • Add EHPad check logic in base class so it applies to all mutation strategies.
  • Fixed a bug causing segmentation fault when invoke/call instruction's callee argument is a pointer.
HazyFish marked an inline comment as done.Apr 25 2023, 5:09 PM
HazyFish updated this revision to Diff 517234.Apr 26 2023, 10:36 AM

Fix format

HazyFish updated this revision to Diff 517325.Apr 26 2023, 2:56 PM
HazyFish retitled this revision from [FuzzMutate] Skip EHPad to avoid crash during mutation to [FuzzMutate] Skip EHPad during mutation and avoid replacing callee with pointer when sinking.
HazyFish edited the summary of this revision. (Show Details)

avoid replacing callee with pointer when sinking

Peter accepted this revision.Apr 26 2023, 4:45 PM
This revision is now accepted and ready to land.Apr 26 2023, 4:45 PM