- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have boiled down a complex "bug" into a very small program which fails to catch an exception when compiled by the Intel C++ compiler (v11), however it works fine on gcc (4.x). Note that on the Intel compiler, it doesn't crash, it just sits there forever. When I ran it through gdb I noticed it seemed to be going into an endless loop in the std::vector destructor (see the code below).
What triggers this bug seems to be the inclusion of the OpenMP parallel directive. If I serialize the little loop by commenting out the #pragma omp parallel for, the exception is succesfully caught, even on the Intel compiler. So it seems to have something to do with the Intel compiler's OpenMP implementation, and how it plays with exceptions. It is a compiler bug, I think, since this code doesn't throw any exceptions inside the parallel region. Please see below:
#include
#include
#include
std::string
bad_func()
{
throw std::exception();
}
int
main(int argc, char* argv[])
{
try {
std::vector v0;
std::vector v1;
bad_func();
#pragma omp parallel for
for(unsigned int q=0; q<8; ++q) {
std::vector u,v;
}
}
catch(std::exception& e) {
std::cerr << e.what() << std::endl;
}
}
I have boiled down a complex "bug" into a very small program which fails to catch an exception when compiled by the Intel C++ compiler (v11), however it works fine on gcc (4.x). Note that on the Intel compiler, it doesn't crash, it just sits there forever. When I ran it through gdb I noticed it seemed to be going into an endless loop in the std::vector destructor (see the code below).
What triggers this bug seems to be the inclusion of the OpenMP parallel directive. If I serialize the little loop by commenting out the #pragma omp parallel for, the exception is succesfully caught, even on the Intel compiler. So it seems to have something to do with the Intel compiler's OpenMP implementation, and how it plays with exceptions. It is a compiler bug, I think, since this code doesn't throw any exceptions inside the parallel region. Please see below:
#include
#include
#include
std::string
bad_func()
{
throw std::exception();
}
int
main(int argc, char* argv[])
{
try {
std::vector
std::vector
bad_func();
#pragma omp parallel for
for(unsigned int q=0; q<8; ++q) {
std::vector
}
}
catch(std::exception& e) {
std::cerr << e.what() << std::endl;
}
}
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much for narrowing the issue down to such small testcase.
Could you let us know the exact icc version you're using? And also the compile options used.
I did a quick test; tried with the latest 11.1.059, with options "icpc -openmp -O2 omp.cpp", it works for me.
Thanks again!
Jennifer
Could you let us know the exact icc version you're using? And also the compile options used.
I did a quick test; tried with the latest 11.1.059, with options "icpc -openmp -O2 omp.cpp", it works for me.
Thanks again!
Jennifer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
btw. use "icc -V" to get the detail compiler package/build info.
Jennifer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Jennifer Jiang (Intel)
btw. use "icc -V" to get the detail compiler package/build info.
Jennifer
Hi Jennifer,
Thanks for your post.
This is the exact command-line invocation I am using for the intel C++ compiler (icpc version 11.1, on 64-bit Linux; Fedora 11).
$ icpc -fexceptions -Wall -fPIC -pipe -fno-common -g3 -O0 -openmp -openmp-report2 main.cc
where 'main.cc' is a text file containing the code I posted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - marcusexoticmatter.com
This is the exact command-line invocation I am using for the intel C++ compiler (icpc version 11.1, on 64-bit Linux; Fedora 11).
I tried only the IA32 compiler. Let me check the x64 compiler. It could be that the bug only exists with the x64 compiler.
Jennifer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks like a bug with the x64 compiler only.
I did find a work-around. Add "-inline-level=1" will work-around the problem.
$icpc -fexceptions -Wall -fPIC -pipe -fno-common -g3 -O0 -inline-level=1-openmp -openmp-report2 main.cc
The default inline-level is 0 when "-O0" is specified.
Let me file a bug report to the compiler.
Thanks for isolating to such small testcase, really appreciated. Otherwise it will take a lot more time before getting to the engineers.
Once there's a fix, I'll let you know by posting a news here. You can also check our bug-fix list. It's updated when a new update is released.
Jennifer
I did find a work-around. Add "-inline-level=1" will work-around the problem.
$icpc -fexceptions -Wall -fPIC -pipe -fno-common -g3 -O0 -inline-level=1-openmp -openmp-report2 main.cc
The default inline-level is 0 when "-O0" is specified.
Let me file a bug report to the compiler.
Thanks for isolating to such small testcase, really appreciated. Otherwise it will take a lot more time before getting to the engineers.
Once there's a fix, I'll let you know by posting a news here. You can also check our bug-fix list. It's updated when a new update is released.
Jennifer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Jennifer Jiang (Intel)
Looks like a bug with the x64 compiler only.
I did find a work-around. Add "-inline-level=1" will work-around the problem.
$icpc -fexceptions -Wall -fPIC -pipe -fno-common -g3 -O0 -inline-level=1-openmp -openmp-report2 main.cc
The default inline-level is 0 when "-O0" is specified.
Let me file a bug report to the compiler.
Thanks for isolating to such small testcase, really appreciated. Otherwise it will take a lot more time before getting to the engineers.
Once there's a fix, I'll let you know by posting a news here. You can also check our bug-fix list. It's updated when a new update is released.
Jennifer
I did find a work-around. Add "-inline-level=1" will work-around the problem.
$icpc -fexceptions -Wall -fPIC -pipe -fno-common -g3 -O0 -inline-level=1-openmp -openmp-report2 main.cc
The default inline-level is 0 when "-O0" is specified.
Let me file a bug report to the compiler.
Thanks for isolating to such small testcase, really appreciated. Otherwise it will take a lot more time before getting to the engineers.
Once there's a fix, I'll let you know by posting a news here. You can also check our bug-fix list. It's updated when a new update is released.
Jennifer
Ok, thanks! The workaround fixes this simple test, but does not help with my real-world app from which the simple test code was derived.
I look forward to this fix! :)
cheers
Marcus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Marcus,
This bug has been fixed. Please download the latest compiler.
Thanks,
Jennifer

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page