This is an archive of the discontinued LLVM Phabricator instance.

[symbolizer] Fix a dangling pointer in LLVMSymbolizer::getOrCreateObjects
AbandonedPublic

Authored by kubamracek on Dec 18 2015, 5:01 AM.

Details

Reviewers
samsonov
Summary

LLVMSymbolizer in getOrCreateObjects() takes ownership of the Binary object it creates, so it's not deallocated early (we're storing pointers to Binary objects in ObjectFileForArch). However, when getObjectFileFromBinary fails (e.g. when the specified architecture is not found), we currently fail to take ownership of Binary. Instead we end up deallocating the object too early and storing a dangling pointer in ObjectFileForArch. This fix calls addOwningBinary even when an error is returned from getObjectFileFromBinary.

Diff Detail

Event Timeline

kubamracek updated this revision to Diff 43219.Dec 18 2015, 5:01 AM
kubamracek retitled this revision from to [symbolizer] Fix a dangling pointer in LLVMSymbolizer::getOrCreateObjects.
kubamracek updated this object.
kubamracek added a reviewer: samsonov.
kubamracek added subscribers: llvm-commits, zaks.anna.
samsonov edited edge metadata.Dec 18 2015, 12:23 PM

This is wrong for several reasons: first of all, there are many calls to getObjectFileFromBinary, and you likely need to do smth. similar for all of them. But then it somewhat defeats the purpose of caching: we essentially keep object files in memory even if they don't have object file for appropriate architecture. Looks like this code needs to be reworked, and at the very least ObjectFileForArch should not have raw pointers as keys. I'll look into that.

Let me know if r256041 fixes a problem for you.

kubamracek abandoned this revision.Jan 5 2016, 6:45 AM

Yes, r256041 seems to have fixed this problem. Thanks!