[PATCH] D89903: [CodeGen] Crash instead of generating broken code with self-capturing __block var
ille via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 22 08:31:57 PDT 2020
ille added a comment.
> We do not actually support allocation failure for a lot of things around blocks. I don't think the copy-helper functions even have a way to propagate out a failure in copying a field. I have never seen any code in the wild that would handle Block_copy returning a null pointer. Effectively it is assumed to not happen.
Fair – although if that's the case, perhaps xnu should not be using blocks. I suppose failures of small allocations like this are rare enough that the issue hasn't come up in practice, and same with the null blocks under ARC.
> It seems somewhat unlikely to me that anyone would actually write code like your example without copying the block and potentially triggering the `__block` variable to be moved to the heap, which is why I think pre-moving the variable might be acceptable.
Also fair. I can implement this, but I do think there should be an associated warning flag.
> With all that said, I agree that crashing and/or just not drilling into the variable is not acceptable.
The patch I submitted switches from not drilling into the variable to crashing. Are you saying I should submit a more thorough fix rather than trying to land this first?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D89903/new/
https://reviews.llvm.org/D89903
More information about the cfe-commits
mailing list