Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
315 Views

Crash by vector destructor if used with range based for loop

Hello,

I have a problem with vector destructor if I use it with range based for loop.

Sample code to reproduce this issue:

#include <vector>

class foo
{
public:
    void bar(const std::vector<int>& ints)
    {
        std::vector<int> items;
#if 1
        for (const auto& i : ints)
        {
#else
        for (size_t j = 0; j < ints.size(); ++j)
        {
            int i = ints;
#endif
            items.push_back(i+5);
        }
    } 
};

int main()
{
    std::vector<int> ints{ 1,2,5,7,9,0 };

    foo f;
    f.bar(ints);

    return 0;
}

The call stack:

>    VectorCrash.exe!std::_Container_base12::_Orphan_all() Line 223    C++
     VectorCrash.exe!std::_Vector_alloc<std::_Vec_base_types<int, std::allocator<int> > >::_Orphan_all() Line 614    C++
     VectorCrash.exe!std::vector<int, std::allocator<int> >::_Tidy() Line 1640    C++
     VectorCrash.exe!std::vector<int, std::allocator<int> >::~vector() Line 977    C++
     VectorCrash.exe!main() Line 36    C++
     VectorCrash.exe!invoke_main() Line 64    C++

It crashes in:

inline void _Container_base12::_Orphan_all()

function in xutility header, when _ITERATOR_DEBUG_LEVEL == 2, also in Debug configuration.

My compiler: Intel® Parallel Studio XE 2017 Update 1 Composer Edition for C++ Windows* Integration for Microsoft* Visual Studio* 2015, Version 17.0.71.14

It works fine with Microsoft C++ compiler.

Best regards

Przemek

0 Kudos
8 Replies
Highlighted
Employee
315 Views

 

Yes this was a bug in 17.0 update 1 that will be fixed in update 2. More info here:

https://software.intel.com/en-us/forums/intel-c-compiler/topic/705086

Judy

0 Kudos
Highlighted
Beginner
315 Views

Thank you. Any clue, when we can expect the update 2?

Best regards

Przemek

0 Kudos
Highlighted
Employee
315 Views

 

I do but I'm not permitted to disclose release dates. Sorry...

0 Kudos
Highlighted
Beginner
315 Views

This bug is really serious problem in young C++ projects, where I use almost everywhere the range based for loops, because they are better than the old, iterator based, or index based, ones. The workaround with replace all of them is not really comfortable solution and will cost a lot of time. I'm sorry too...

0 Kudos
Highlighted
Beginner
315 Views

I find myself in the very same position as Przemyslaw O. The proposed workaround is not really applicable to large scale projects, not to mention that it may induce additional bugs and lesser the overall quality of the deliverables compiled after applying the heavy changes to the source code imposed by this very serious bug. This is a core c++11 functionality. Nowadays we are discussing c++17, this functionality should really be included in unit testing of the compiler and caught by Intel technicians before Intel ships the product. I'm sorry too. We are paying customer but are currently forced to use other compilers because of this very serious bug.

0 Kudos
Highlighted
Beginner
315 Views

I will try one more time. If Judith W. (Intel) can not tell us when Intel plans release of update 2, probably there is here someone from Intel who can do this. This bug is known since December 13. We buyed Intel compiler and have to switch back to Microsoft compiler because it's quite difficult to develop with this bug inside.

0 Kudos
Highlighted
Beginner
315 Views

Compile with _ITERATOR_DEBUG_LEVEL=1 for your debug targets and wait patiently for an update.

0 Kudos
Highlighted
Moderator
315 Views

Update to this thread.

The 17.0 Update 2 has out that contains the fix for this issue. please download it from Intel Registration and Download Center: https://registrationcenter.intel.com/RegCenter/Register.aspx 

thanks,

Jennifer

0 Kudos