[PATCH] D86256: [libunwind] Make .eh_frame scanning/caching optional

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 13 13:36:32 PDT 2020


mstorsjo added a comment.

In D86256#2244077 <https://reviews.llvm.org/D86256#2244077>, @rprichard wrote:

>> If the unwinder uses dl_iterate_phdr, then entries that are automatically added to DwarfFDECache would become invalid if the module containing the entry were unloaded. (On Apple systems, DwarfFDECache registers dyldUnloadHook to remove unloaded entries.)
>
> AFAICT, this is also a problem for Windows DWARF EH, which relies on scanning an .eh_frame section. e.g. A stale cachedFDE could point into the middle of an FDE/CIE with an arbitrary outcome. Maybe decodeFDE crashes, or maybe it decodes something that looks like a match. I'm not sure if it can be fixed without disabling the caching. If so, then I'd wonder if the caching is worth keeping. (Bare-metal could use .eh_frame_hdr, and I'm not sure whether Apple systems actually need the full __eh_frame scan.)

Indeed, that's correct. I guess a stale cache entry would only ever be hit if there's another DLL loaded into the same address range as the previous one, but if that happens and unwidning hits a cached entry, pretty much anything could happen. Not really sure if there's any good callbacks for when other DLLs are unloaded...

Disabling the cache in those cases might be safest - even though it probably gives a good speedup for all practical cases, the risks it imposes are pretty bad as well...

> Windows also has SEH exceptions, which I think don't have this problem.

It's handled quite differently there, yeah.

Regarding the rest of the patch, I don't have enough experience with these details on ELF platforms to have much of an informed opinion... The windows specific bits look good though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86256/new/

https://reviews.llvm.org/D86256



More information about the llvm-commits mailing list