Debug Assertion failed! Expression: _pfirstblock = = Phead

Source: Internet
Author: User

Click Abort, look at the call stack, found that the exception is generated when the function return, further see is the vector destructor is called to produce, not previously developed C + + project, no experience, this error let me very confused, first, I do not have an F disk on the computer; I did not call the destructor; third, what a mistake.

The first question, probably a virtual partition, the second problem, my vector variable is used within a function body declaration, when the function returns, the automatic variable life end, C + + should call the vector destructor to release the object, at this time an exception occurred.

On the third question, I looked up some information on the internet and found that there are some situations

1. Confusing debug and release situation, sometimes debug and release need the library is not the same, if you only import the release of the link library, and not import debug link library, and the compile run and select the debug mode, this problem may occur, At this point to add the Debug link library can be resolved.

2. May be in a multithreaded module run a single-line libraries, within the existence of DLL side is allocated, on the use side is freed, may cause a memory manager in allocating memory, another memory manager in the release of the same piece of memory area, resulting in an error.

C + + STL is single-threaded, I use a vector inside the function, this function in a multithreaded environment, is probably the cause of this error.

One solution is to set the runtime to/MDd

Project Right Button-"Properties-" c/c++= "all options

About the runtime several parameters

Multithreading (/MT)
multithreaded Debugging (/MTD)
multithreaded DLLs (/MD)
Multithreaded debug DLLs (/MDD)

After the name with D is the debug library, the name contains d is a dynamic link, including T is a static link


C run-Time library files
multithread (static link) MT LIBCMT.lib
Debug multithread (static link) MTd LIBCMTD.lib
multithread (dynamic link) MD msvert.lib
Debug multithread (dynamic link) MDd msvertd.lib

Another: Workaround for this error when using std::string

Http://stackoverflow.com/questions/18882760/debug-assertion-failed-expression-pfirstblock-phead

Debug Assertion failed! Expression: _pfirstblock = = Phead

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.