-
September 10th, 2012, 09:23 PM
#1
Debug assertion failed ! problem
Hi,
I am having this problem when i try to execute the .exe of my application
"Debug assertion failed !, Expression invalid null pointer"
After a bit of googling i think so i know where the problem lies, but have no idea how to solve it.
Below is the relevant piece of code.
size_t idx;
// create the initial texture
atlases.push_back(new TextureAtlas( image_names.size()));
// load the texture
for (idx = 0; idx < image_names.size(); ++idx) {
//load the image
TextureInformation *ti = new TextureInformation (idx, folder_location_str, image_names[idx]);
During the execution of the code at the line where ti is initialized and declared the values at local tab(in ms visual c++ 2008) are something like below.
ti TextureInformation *
idx CXX0030: Error: expression cannot be evaluated
image_path {npos=4294967295 _Bx={...} _Mysize=??? ...} std::basic_string<char,std::char_traits<char>,std::allocator<char> >
image_name {npos=4294967295 _Bx={...} _Mysize=??? ...} std::basic_string<char,std::char_traits<char>,std::allocator<char> >
image CXX0017: Error: symbol "" not found
For some reason: idx and image shows error here and this only happens during the first iteration of the for loop. Below is the content of ti during the second iteration
idx 0 unsigned int
+ image_path ".....Related\PNG\" std::basic_string<char,std::char_traits<char>,std::allocator<char> >
+ image_name "basn0g01.png" std::basic_string<char,std::char_traits<char>,std::allocator<char> >
+ image 0x00812830 {m_info={...} m_pixbuf={...} } png::image<png::basic_rgba_pixel<unsigned char> > *
This is how my TextualInformation looks
class TextureInformation
{
public:
TextureInformation(size_t index, std::string path, std::string name)
: idx(index), image_path(path), image_name(name)
{
image = new png::image<png::rgba_pixel>(image_path + image_name,
png::convert_color_space<png::rgba_pixel>());
}
~TextureInformation(void)
{
delete image;
}
....
....
private:
size_t idx;
std::string image_path;
std::string image_name;
png::image<png::rgba_pixel>* image;
};
Please tell me if other details are required. Thanks
-
September 10th, 2012, 10:16 PM
#2
Re: Debug assertion failed ! problem
You should check return values and/or catch exceptions as appropriate.
-
September 11th, 2012, 10:16 AM
#3
Re: Debug assertion failed ! problem
Originally Posted by salmanmanekia
Hi,
I am having this problem when i try to execute the .exe of my application
First, use code tags when posting code, as the code is almost unreadable without them.
"Debug assertion failed !, Expression invalid null pointer"
After a bit of googling i think so i know where the problem lies,
Seriously, did you really need google to tell you that your program has a memory corruption bug or you're mishandling pointers? Also, google knows nothing about your program or anyone else's program, so looking at google for an answer isn't an option. The only one that can fix your program is you and anyone else who happens to have all of your code.
Below is the relevant piece of code.
"Relevant code" in your case requires the entire code as well as the data used to drive the code so that everyone here can run the code and tell you what to fix.
No one knows what's behind those variables you posted, the state of the program when the corruption occurs, the flow and the logic of the program, etc. All of these are required for others to diagnose memory run-time issues. Just posting a few lines of code that are syntactically correct will not help.
For example, I've just broken your objects with this 2 line program:
Code:
int main()
{
TextureInformation ti1(0, "c:\\test", "somename");
TextureInformation ti2 = ti1;
}
That code will cause a double deletion error at the return of main(). So I've just broken your class. See why we need to see the exact code you're running?
Regards,
Paul McKenzie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|