Community
cancel
Showing results for 
Search instead for 
Did you mean: 
glavny
Beginner
413 Views

dangling pointer check failed

I have a simple and errorless C++ code.

If I turn "All (/Qcheck-pointers-dangling:all)", program failed with message and system exception:

CHKP: Bounds check error ptr=0X00000022EB6191C0 sz=4 lb=0X0000000000000002 ub=0000000000000000 loc=0X00007FF64E191A88

"Unhandled exception at 0x00007FF98CF7DA4A (ntdll.dll) in ConsoleApplication5.exe: A LIST_ENTRY has been corrupted (i.e. double remove)."

Building with Intel(R) C++ Compiler 16.0, ClCompile (x64 - Intel C++)

struct ctest
{
	std::vector<int>		plan_;

	ctest(void* h, uint8_t pid, size_t blk_size, size_t blk_num)
	{
		foo();
	}

	ctest()
	{
		foo();
	}

	void foo()
	{
		plan_.push_back(1);
		auto& v = plan_.back();
		v = 0;
	}
};

void foo_1(void)
{
	ctest buf_(0,0,0,0);
}

void foo_2(void)
{
	ctest buf_();
}

int main()
{
	// passed
	for (int i = 0; i < 64; ++i)
	{
		std::thread d(foo_2);
		d.join();
	}
	// failed at 64th iteration
	for (int i = 0; i < 64; ++i)
	{
		std::thread d(foo_1);
		d.join();
	}
    return 0;
}

 

0 Kudos
5 Replies
pbkenned1
Employee
413 Views

Thanks for submitting the issue.  I can't reproduce it with 16.0.2 using the command line.  What version of 16.0 are you using?  Can you reproduce the issue from the command line, and what is your command line?  I haven't looked at your VS solution.

C:\ISN_Forums\U621669>icl U621669.cpp /Qcheck-pointers:rw /Qcheck-pointers-dangling:all
Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.2.180 Build 20160204
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

U621669.cpp
Microsoft (R) Incremental Linker Version 12.00.21005.1
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:U621669.exe
U621669.obj

C:\ISN_Forums\U621669>U621669.exe

C:\ISN_Forums\U621669>

Patrick

Kittur_G_Intel
Employee
413 Views

Hi Pat, I tried the test reproducer  in VS2015 as well and command line as well. I couldn't reproduce the issue and so you'll need to get more details from @glavny.

Kittur

glavny
Beginner
413 Views

From command line all right, even with loop constant 128*1024.
icl CA5.cpp /Qcheck-pointers:rw /Qcheck-pointers-dangling:all
>icl CA5.cpp /Qcheck-pointers:rw /Qcheck-pointers-dangling:all

Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.1.146 Build 20151021
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

CA5.cpp
Microsoft (R) Incremental Linker Version 14.00.23506.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:CA5.exe
CA5.obj

My VS project with output log attached to the initial post. I copied compiler and linker command lines (attached cmd.txt)

 

 

glavny
Beginner
413 Views

I found solution:

Linker/Advanced/Randomized Base Address: switch from YES to NO.

But I don't know how and why this work.

 

Kittur_G_Intel
Employee
413 Views

Hi, 
The check-pointers-dangling option is a feature useful for debug configuration only. It tries to track the memory that is allocated and freed. Unfortunately, Windows address randomization tries to allocate memory from random addresses. This is not compatible with the dangling pointer checking, because repeated memory allocation calls may get very different addresses.  BTW, I've confirmed with the development team on this as well and I have requested that the option elaboration of what I stated be added to the documentation pertaining to the feature as well. Thanks for catching this issue and bringing this to our attention, appreciate much.
Kittur
 

Reply