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

Lots of sketchy behaviour masked by RecyclingAllocator #27182

Open
bogner opened this issue Mar 2, 2016 · 4 comments
Open

Lots of sketchy behaviour masked by RecyclingAllocator #27182

bogner opened this issue Mar 2, 2016 · 4 comments
Labels
bugzilla Issues migrated from bugzilla

Comments

@bogner
Copy link
Contributor

bogner commented Mar 2, 2016

Bugzilla Link 26808
Version trunk
OS All
Attachments Patch to make Recycler asan-aware
CC @ahmedbougacha,@chandlerc,@hfinkel,@mikaelholmen,@cooperp,@sanjoy,@rotateright,@vedantk

Extended Description

The attached patch teaches Recycler (and by proxy RecyclingAllocator) to poison and unpoison memory for ASAN. Running ninja check under ASAN with this applied hits a few thousand failures. Some of the issues include:

  • We don't allocate nodes in SelectionDAG correctly - we always call an SDNode allocator and upcast to the (much larger) subclasses. This mostly works since the RecyclingAllocator is set to allocate 296 bytes per node.

  • SelectionDAG sets node types to "ISD::DELETED_NODE" before returning them to the free list, ostensibly to detect bugs. Then it uses whether or not the thing is deleted for control flow in places like UpdateChainsAndGlue. This should not work, but apparently it tends to in practice.

  • SelectionDAG arbitrarily casts from smaller SDNodes to MachineSDNode in MorphNodeTo. This is very much undefined behaviour, but basically works since the allocations happen to be large enough.

  • There's probably a use-after-free of Tail in TargetInstrInfo::ReplaceTailWithBranchTo.

  • RegisterCoalescer::reMaterializeTrivialDef appears to have use-after-free bugs regarding MachineInstrs.

@hfinkel
Copy link
Collaborator

hfinkel commented Mar 2, 2016

Wow. s/sketchy/incorrect/

@bogner
Copy link
Contributor Author

bogner commented Mar 2, 2016

r262500 makes us allocate SDNodes with correct sizes

@cooperp
Copy link
Contributor

cooperp commented Mar 3, 2016

Looking at UpdateChainsAndGlue. The likely culprit is the dead nodes set in MorphNodeTo. We need the nodes killed in MorphNodeTo to be removed from the lists passed to UpdateChainsAndGlue.

Also, all of this is horrible!

@bogner
Copy link
Contributor Author

bogner commented Apr 14, 2016

All of the errors outside of SelectionDAG are fixed as of r266150, r266130, r264470, r264455, r264443, and r264442. SelectionDAG's harder, and I'll continue to dig into that.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

3 participants