This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] Avoid expr buffer reuse when end_associate may cycle.
ClosedPublic

Authored by vzakhari on Jul 19 2023, 9:27 PM.

Details

Summary

If end_associate may execute more times than the expr value producer,
then it cannot take ownership of the expr buffer. Otherwise, it may
result in double-free errors.
Note that the LIT test exposes a different issue with fir.alloca
inside the do-loop produced for hlfir.elemental. This may cause
out-of-stack conditions in valid Fortran programs that are not expected
to run out of stack. I will create an issue for this.

Diff Detail

Event Timeline

vzakhari created this revision.Jul 19 2023, 9:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2023, 9:27 PM
vzakhari requested review of this revision.Jul 19 2023, 9:27 PM
tblah accepted this revision.Jul 20 2023, 9:28 AM

LGTM, thanks for finding and fixing this!

This revision is now accepted and ready to land.Jul 20 2023, 9:28 AM
This revision was landed with ongoing or failed builds.Jul 20 2023, 10:18 AM
This revision was automatically updated to reflect the committed changes.

For bookkeeping, I created https://github.com/llvm/llvm-project/issues/63989 for the potential stack oveflow.