This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Fix potentially inconsistent OMPT return address
AbandonedPublic

Authored by hbae on Oct 23 2020, 2:56 PM.

Details

Summary

Current OMPT_STORE_RETURN_ADDRESS() is not allowed to overwrite the return
address of the thread, opening the possibility for the thread to keep
obsolete information when it encounters the next construct without consuming
the information. Return address should be overwritten to avoid this.

Diff Detail

Event Timeline

hbae created this revision.Oct 23 2020, 2:56 PM
hbae requested review of this revision.Oct 23 2020, 2:56 PM

This will break many cases, where GOMP or even kmp functions call external kmpc functions rather than only internal kmp functions. In such case, the return address will point to the runtime function.
The idea of the macro is to ensure that only the first entry to the runtime will set the address.
Before we can make this change (and I would be more than happy about this change ;), we need to make sure, that no runtime code calls the external __kmpc interface (at least, if the external function tries to store the return address).

Examples for calls to __kmpc functions in the runtime code:

https://github.com/llvm/llvm-project/blob/master/openmp/runtime/src/kmp_runtime.cpp#L1515
https://github.com/llvm/llvm-project/blob/master/openmp/runtime/src/kmp_runtime.cpp#L1745
https://github.com/llvm/llvm-project/blob/master/openmp/runtime/src/kmp_runtime.cpp#L2352

https://github.com/llvm/llvm-project/blob/master/openmp/runtime/src/kmp_tasking.cpp#L2339

And many calls in the GOMP interface implementation:
https://github.com/llvm/llvm-project/blob/master/openmp/runtime/src/kmp_gsupport.cpp

protze.joachim requested changes to this revision.Oct 27 2020, 4:07 PM
This revision now requires changes to proceed.Oct 27 2020, 4:07 PM
hbae added a comment.Oct 28 2020, 8:04 AM

@protze.joachim, you are right.
I will come back to this with a test case and a correct fix.

hbae abandoned this revision.Nov 25 2020, 9:31 AM

Addressed by D91692.