[Openmp-dev] exception throwing from a copy constructor for a firstprivate

Natalia Glagoleva via Openmp-dev openmp-dev at lists.llvm.org
Tue Dec 14 11:18:54 PST 2021


In Standard 5.2 I see these two phrases:

(p 48, 16-19) A throw executed inside a region that arises from a thread-limiting directive must cause 17 execution to resume within the same region, and the same thread that threw the exception must 18 catch it. If the directive is also exception-aborting then whether the exception is caught or the 19 throw results in runtime error termination is implementation defined.

(p 617, 3-4) Whether a throw executed inside a region that arises from an exception-aborting directive 4 results in runtime error termination is implementation defined (see Section 3.1).

I am trying the attached test,
clang -O0 task_ftp_EH3_noeh.cpp  -DNOISY -DCOUNT=2 -fopenmp

The essential part:

void main_test(MyObject* pTree, int i) {

    if (!pTree) return;

#pragma omp parallel default(none) shared(i, pTree) num_threads(NUM_THREADS)
#pragma omp single
    {
        while (pTree) {
            try {
                MyObject tree(*pTree);

#pragma omp task firstprivate(i, tree)
                {
                    ...
                    main_test(tree.right, i + 4);
                }
                  ...
            }
            catch (std::exception) {
                ...
            }
            ...
        }
    }
}
Where copy constructor for 'tree' throws when it's called for firstprivate clause (called second time).
My assumption was that the clause is computed in the 'single' region, not 'task' region, and catch is there too, so I thought that technically it should be legal and catch should work.
This is hanging in the runtime, verified with llvm 13 release.

Is it a bug?

Thank you,
Natalia Glagoleva


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20211214/6f7a46c9/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: task_ftp_EH3_noeh.cpp
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20211214/6f7a46c9/attachment.ksh>


More information about the Openmp-dev mailing list