Debug Assertion Failed! Visual Studio 2012 (C++)










0














Can someone help me regarding this problem. The popup will display "Debug Assertion Failed"




Expression : _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)




enter image description here



I try debug on line it mention it will display unable to read memory. May someone tell me what cause this?



enter image description here



This my code:



#include "cpl_conv.h" // for CPLMalloc()
#include "stdafx.h"
#include "gdal.h"
#include <stdlib.h>
#include <stdio.h>
#include "iostream"
#include "gdal_priv.h"




class GDALMajorObject;
class GDALDataset;
class GDALRasterBand;
class GDALDriver;
class GDALRasterAttributeTable;
class GDALProxyDataset;
class GDALProxyRasterBand;
class GDALAsyncReader;




int main(int argc,char* argv)


GDALDataset *poDataset;
//GDALDatasetH *poDatasetH;
const char* Raster = new char[256];
double adfGeoTransform[6];


GDALAllRegister();

Raster = "C:\Users\User\Desktop\DSI REFERENCE\Map Data\Raster\4257.tif";

poDataset = (GDALDataset *) GDALOpen(Raster, GA_ReadOnly )CPL_WARN_UNUSED_RESULT;
//poDataset = (GDALDataset *) GDALOpen(Raster, GA_ReadOnly );

if( poDataset == NULL )

printf("Not found");

else

printf( "Driver: %s/%sn",
poDataset->GetDriver()->GetDescription(),
poDataset->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME ) );

printf( "Size is %dx%dx%dn",
poDataset->GetRasterXSize(), poDataset->GetRasterYSize(),
poDataset->GetRasterCount() );

if( poDataset->GetProjectionRef() != NULL )
printf( "Projection is `%s'n", poDataset->GetProjectionRef() );

if( poDataset->GetGeoTransform( adfGeoTransform ) == CE_None )

printf( "Origin = (%.6f,%.6f)n",
adfGeoTransform[0], adfGeoTransform[3] );
printf( "Pixel Size = (%.6f,%.6f)n",
adfGeoTransform[1], adfGeoTransform[5] );





// make it 256 bytes for a string length of 255 plus null () terminator



// your code
delete Raster;// release the memory VERY IMPORTANT












share|improve this question





















  • Why do you delete a string literal?
    – tkausl
    Nov 13 '18 at 3:10










  • @tkausl i don't understand. If i use string it will display IntelliSense: a value of type "char *" cannot be used to initialize an entity of type "std::string *"
    – Mohamad Fathin
    Nov 13 '18 at 3:31











  • const char* Raster = new char[256]; Raster = "whatever"; The second statement here leaks memory allocated by the first, and makes Raster point to statically-allocated memory (rather than dynamically-allocated one). delete Raster then exhibits undefined behavior, as the memory currently pointed to by Raster was not in fact allocated with new. Make it const char* Raster = "whatever"; and drop the delete statement.
    – Igor Tandetnik
    Nov 13 '18 at 3:45










  • @IgorTandetnik thank for your solution. Solve the problem. DId you have any reference that i can read about it?
    – Mohamad Fathin
    Nov 13 '18 at 5:31















0














Can someone help me regarding this problem. The popup will display "Debug Assertion Failed"




Expression : _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)




enter image description here



I try debug on line it mention it will display unable to read memory. May someone tell me what cause this?



enter image description here



This my code:



#include "cpl_conv.h" // for CPLMalloc()
#include "stdafx.h"
#include "gdal.h"
#include <stdlib.h>
#include <stdio.h>
#include "iostream"
#include "gdal_priv.h"




class GDALMajorObject;
class GDALDataset;
class GDALRasterBand;
class GDALDriver;
class GDALRasterAttributeTable;
class GDALProxyDataset;
class GDALProxyRasterBand;
class GDALAsyncReader;




int main(int argc,char* argv)


GDALDataset *poDataset;
//GDALDatasetH *poDatasetH;
const char* Raster = new char[256];
double adfGeoTransform[6];


GDALAllRegister();

Raster = "C:\Users\User\Desktop\DSI REFERENCE\Map Data\Raster\4257.tif";

poDataset = (GDALDataset *) GDALOpen(Raster, GA_ReadOnly )CPL_WARN_UNUSED_RESULT;
//poDataset = (GDALDataset *) GDALOpen(Raster, GA_ReadOnly );

if( poDataset == NULL )

printf("Not found");

else

printf( "Driver: %s/%sn",
poDataset->GetDriver()->GetDescription(),
poDataset->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME ) );

printf( "Size is %dx%dx%dn",
poDataset->GetRasterXSize(), poDataset->GetRasterYSize(),
poDataset->GetRasterCount() );

if( poDataset->GetProjectionRef() != NULL )
printf( "Projection is `%s'n", poDataset->GetProjectionRef() );

if( poDataset->GetGeoTransform( adfGeoTransform ) == CE_None )

printf( "Origin = (%.6f,%.6f)n",
adfGeoTransform[0], adfGeoTransform[3] );
printf( "Pixel Size = (%.6f,%.6f)n",
adfGeoTransform[1], adfGeoTransform[5] );





// make it 256 bytes for a string length of 255 plus null () terminator



// your code
delete Raster;// release the memory VERY IMPORTANT












share|improve this question





















  • Why do you delete a string literal?
    – tkausl
    Nov 13 '18 at 3:10










  • @tkausl i don't understand. If i use string it will display IntelliSense: a value of type "char *" cannot be used to initialize an entity of type "std::string *"
    – Mohamad Fathin
    Nov 13 '18 at 3:31











  • const char* Raster = new char[256]; Raster = "whatever"; The second statement here leaks memory allocated by the first, and makes Raster point to statically-allocated memory (rather than dynamically-allocated one). delete Raster then exhibits undefined behavior, as the memory currently pointed to by Raster was not in fact allocated with new. Make it const char* Raster = "whatever"; and drop the delete statement.
    – Igor Tandetnik
    Nov 13 '18 at 3:45










  • @IgorTandetnik thank for your solution. Solve the problem. DId you have any reference that i can read about it?
    – Mohamad Fathin
    Nov 13 '18 at 5:31













0












0








0







Can someone help me regarding this problem. The popup will display "Debug Assertion Failed"




Expression : _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)




enter image description here



I try debug on line it mention it will display unable to read memory. May someone tell me what cause this?



enter image description here



This my code:



#include "cpl_conv.h" // for CPLMalloc()
#include "stdafx.h"
#include "gdal.h"
#include <stdlib.h>
#include <stdio.h>
#include "iostream"
#include "gdal_priv.h"




class GDALMajorObject;
class GDALDataset;
class GDALRasterBand;
class GDALDriver;
class GDALRasterAttributeTable;
class GDALProxyDataset;
class GDALProxyRasterBand;
class GDALAsyncReader;




int main(int argc,char* argv)


GDALDataset *poDataset;
//GDALDatasetH *poDatasetH;
const char* Raster = new char[256];
double adfGeoTransform[6];


GDALAllRegister();

Raster = "C:\Users\User\Desktop\DSI REFERENCE\Map Data\Raster\4257.tif";

poDataset = (GDALDataset *) GDALOpen(Raster, GA_ReadOnly )CPL_WARN_UNUSED_RESULT;
//poDataset = (GDALDataset *) GDALOpen(Raster, GA_ReadOnly );

if( poDataset == NULL )

printf("Not found");

else

printf( "Driver: %s/%sn",
poDataset->GetDriver()->GetDescription(),
poDataset->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME ) );

printf( "Size is %dx%dx%dn",
poDataset->GetRasterXSize(), poDataset->GetRasterYSize(),
poDataset->GetRasterCount() );

if( poDataset->GetProjectionRef() != NULL )
printf( "Projection is `%s'n", poDataset->GetProjectionRef() );

if( poDataset->GetGeoTransform( adfGeoTransform ) == CE_None )

printf( "Origin = (%.6f,%.6f)n",
adfGeoTransform[0], adfGeoTransform[3] );
printf( "Pixel Size = (%.6f,%.6f)n",
adfGeoTransform[1], adfGeoTransform[5] );





// make it 256 bytes for a string length of 255 plus null () terminator



// your code
delete Raster;// release the memory VERY IMPORTANT












share|improve this question













Can someone help me regarding this problem. The popup will display "Debug Assertion Failed"




Expression : _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)




enter image description here



I try debug on line it mention it will display unable to read memory. May someone tell me what cause this?



enter image description here



This my code:



#include "cpl_conv.h" // for CPLMalloc()
#include "stdafx.h"
#include "gdal.h"
#include <stdlib.h>
#include <stdio.h>
#include "iostream"
#include "gdal_priv.h"




class GDALMajorObject;
class GDALDataset;
class GDALRasterBand;
class GDALDriver;
class GDALRasterAttributeTable;
class GDALProxyDataset;
class GDALProxyRasterBand;
class GDALAsyncReader;




int main(int argc,char* argv)


GDALDataset *poDataset;
//GDALDatasetH *poDatasetH;
const char* Raster = new char[256];
double adfGeoTransform[6];


GDALAllRegister();

Raster = "C:\Users\User\Desktop\DSI REFERENCE\Map Data\Raster\4257.tif";

poDataset = (GDALDataset *) GDALOpen(Raster, GA_ReadOnly )CPL_WARN_UNUSED_RESULT;
//poDataset = (GDALDataset *) GDALOpen(Raster, GA_ReadOnly );

if( poDataset == NULL )

printf("Not found");

else

printf( "Driver: %s/%sn",
poDataset->GetDriver()->GetDescription(),
poDataset->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME ) );

printf( "Size is %dx%dx%dn",
poDataset->GetRasterXSize(), poDataset->GetRasterYSize(),
poDataset->GetRasterCount() );

if( poDataset->GetProjectionRef() != NULL )
printf( "Projection is `%s'n", poDataset->GetProjectionRef() );

if( poDataset->GetGeoTransform( adfGeoTransform ) == CE_None )

printf( "Origin = (%.6f,%.6f)n",
adfGeoTransform[0], adfGeoTransform[3] );
printf( "Pixel Size = (%.6f,%.6f)n",
adfGeoTransform[1], adfGeoTransform[5] );





// make it 256 bytes for a string length of 255 plus null () terminator



// your code
delete Raster;// release the memory VERY IMPORTANT









visual-c++ gdal assertion






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 3:08









Mohamad FathinMohamad Fathin

102




102











  • Why do you delete a string literal?
    – tkausl
    Nov 13 '18 at 3:10










  • @tkausl i don't understand. If i use string it will display IntelliSense: a value of type "char *" cannot be used to initialize an entity of type "std::string *"
    – Mohamad Fathin
    Nov 13 '18 at 3:31











  • const char* Raster = new char[256]; Raster = "whatever"; The second statement here leaks memory allocated by the first, and makes Raster point to statically-allocated memory (rather than dynamically-allocated one). delete Raster then exhibits undefined behavior, as the memory currently pointed to by Raster was not in fact allocated with new. Make it const char* Raster = "whatever"; and drop the delete statement.
    – Igor Tandetnik
    Nov 13 '18 at 3:45










  • @IgorTandetnik thank for your solution. Solve the problem. DId you have any reference that i can read about it?
    – Mohamad Fathin
    Nov 13 '18 at 5:31
















  • Why do you delete a string literal?
    – tkausl
    Nov 13 '18 at 3:10










  • @tkausl i don't understand. If i use string it will display IntelliSense: a value of type "char *" cannot be used to initialize an entity of type "std::string *"
    – Mohamad Fathin
    Nov 13 '18 at 3:31











  • const char* Raster = new char[256]; Raster = "whatever"; The second statement here leaks memory allocated by the first, and makes Raster point to statically-allocated memory (rather than dynamically-allocated one). delete Raster then exhibits undefined behavior, as the memory currently pointed to by Raster was not in fact allocated with new. Make it const char* Raster = "whatever"; and drop the delete statement.
    – Igor Tandetnik
    Nov 13 '18 at 3:45










  • @IgorTandetnik thank for your solution. Solve the problem. DId you have any reference that i can read about it?
    – Mohamad Fathin
    Nov 13 '18 at 5:31















Why do you delete a string literal?
– tkausl
Nov 13 '18 at 3:10




Why do you delete a string literal?
– tkausl
Nov 13 '18 at 3:10












@tkausl i don't understand. If i use string it will display IntelliSense: a value of type "char *" cannot be used to initialize an entity of type "std::string *"
– Mohamad Fathin
Nov 13 '18 at 3:31





@tkausl i don't understand. If i use string it will display IntelliSense: a value of type "char *" cannot be used to initialize an entity of type "std::string *"
– Mohamad Fathin
Nov 13 '18 at 3:31













const char* Raster = new char[256]; Raster = "whatever"; The second statement here leaks memory allocated by the first, and makes Raster point to statically-allocated memory (rather than dynamically-allocated one). delete Raster then exhibits undefined behavior, as the memory currently pointed to by Raster was not in fact allocated with new. Make it const char* Raster = "whatever"; and drop the delete statement.
– Igor Tandetnik
Nov 13 '18 at 3:45




const char* Raster = new char[256]; Raster = "whatever"; The second statement here leaks memory allocated by the first, and makes Raster point to statically-allocated memory (rather than dynamically-allocated one). delete Raster then exhibits undefined behavior, as the memory currently pointed to by Raster was not in fact allocated with new. Make it const char* Raster = "whatever"; and drop the delete statement.
– Igor Tandetnik
Nov 13 '18 at 3:45












@IgorTandetnik thank for your solution. Solve the problem. DId you have any reference that i can read about it?
– Mohamad Fathin
Nov 13 '18 at 5:31




@IgorTandetnik thank for your solution. Solve the problem. DId you have any reference that i can read about it?
– Mohamad Fathin
Nov 13 '18 at 5:31












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273201%2fdebug-assertion-failed-visual-studio-2012-c%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273201%2fdebug-assertion-failed-visual-studio-2012-c%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto