Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug Assertion Expression: _pFirstBlock == pHead #9

Closed
kylim opened this issue Jun 9, 2014 · 8 comments
Closed

Debug Assertion Expression: _pFirstBlock == pHead #9

kylim opened this issue Jun 9, 2014 · 8 comments

Comments

@kylim
Copy link

kylim commented Jun 9, 2014

The following assertion error is triggered after updating to version 0.3, but it does not happen with the version 0.2 build.

Debug Assertion Failed!
Program: F:\0Main\Tools\AzureTester\Debug\AzureTester.exe
File: f:\dd\vctools\crt\crtw32\misc\dbgheap.c
Line: 1424
Expression: _pFirstBlock == pHead

The code that triggers this assertion is:
azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(storage_connection_string);
azure::storage::cloud_table_client table_client = storage_account.create_cloud_table_client();
azure::storage::cloud_table table = table_client.get_table_reference(U("testtable"));

and the only difference between this code and the one used in 0.2 is the change in the namespace from wa::storage to azure::storage. The assertion only appears in the debug build and not in the release build, but in release build it appears to cause failures down the line that results in exceptions that do not happen when using the 0.2 build. Library was downloaded via nuget, I'm using VS2013 on x64,

@kylim
Copy link
Author

kylim commented Jun 16, 2014

Just an update on this issue, it appears to only happen when using the Azure library in an MFC project that is used statically.

@MFisherMSFT
Copy link
Contributor

We were unable to reproduce the error you are seeing using the sample code you provided. The error could be caused by an invalid storage connection string. Could you please double check that your storage connection string has a valid format?

-Mike Fisher, Microsoft Azure Storage

@kylim
Copy link
Author

kylim commented Jun 18, 2014

I am using "UseDevelopmentStorage=true" for the emulator but this is irrelevant as the connection string isn't the cause. The simplest way to reproduce this issue is to take the Microsoft.WindowsAzure.Storage.TablesGettingStarted.v120 sample project and change the Use of MFC setting from "Use Standard Windows Libraries" to "Use MFC in a Static Library". The assertion is triggered at the line
azure::storage::cloud_table table = table_client.get_table_reference(U("MySampleTable"));

The assertion is not triggered if Use of MFC is set to "Shared DLL".

@kylim kylim closed this as completed Jun 18, 2014
@kylim kylim reopened this Jun 18, 2014
@MFisherMSFT
Copy link
Contributor

Thank you for the detailed repo steps. I am seeing the same assertion using the sample project as you suggested. I do not see the assertion using a fresh MFC project (because it uses /MDd, see below…).

The root cause of the problem is memory is being allocated in the Azure Storage library (or REST SDK library, which is a dependency of ours). Then the memory is being freed in your application. These are using different heaps, so they are getting confused.

A solution is to compile your application with the /MT or /MTd option instead of /MD or /MDd. See: http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx. This will make a multithreaded module a DLL.

@kylim
Copy link
Author

kylim commented Jun 20, 2014

The assertion is still triggered for me when compiled with either /MT or /MTd with the sample project. In fact the sample projects are configured to use /MT and /MTd by default.

@MFisherMSFT
Copy link
Contributor

Sorry, I got those backwards. I meant to say, compile your application with the /MD or /MDd option instead of /MT or /MTd.

@myd7349
Copy link

myd7349 commented Mar 10, 2015

@MFisherMSFT Thank you!
I encountered the same problem and got it solved according to your answer.

@kylim kylim closed this as completed Mar 10, 2015
@watermel
Copy link

@MFisherMSFT Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants