access violation problems of ImageLoader::LoadImage()

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
apollon002
Posts: 1
Joined: 2011-03-13T23:59:46-07:00
Authentication code: 8675308

access violation problems of ImageLoader::LoadImage()

Post by apollon002 »

i'm from China , and i wonder whether my poor english could descripe this problem precisely

here is my problem

these days i 'm doing some research with other's code,it's for the linux,
in his code ,he defined a class named ImageLoader,
which worked fine , but i need to transplant it to the windows,lots of problems comes up,
and now ,my problem is eachtime i run the program , there will be an access violatin happened,
i found the violation point is this member function , read(filename),i don't know how to debug this dll further,
i will appreciate it if you can tell me what to do ,THX !!!!!!
here is his original code :

Code: Select all

bool ImageLoader::LoadImage(const string& filename,
                            Image* out_image, string* out_filename) const {
  assert(out_image != NULL);
  assert(out_filename != NULL);
      
  cout<<filename<<endl;
  out_image->read(filename); //here is the point of an access violation happened
    cout<<"t+1"<<endl;

  if (AcceptsFormat(out_image->magick())) {
    *out_filename = filename;
    return true;
  } else {
    out_image->magick(preferred_format_);
  
    char temp_file_name[1024];
    sprintf(temp_file_name, "D:\\tmp\\libpmk_loader.%d.XXXXXX", getpid());
	mktemp(temp_file_name);
  
    out_image->write(temp_file_name);
    *out_filename = temp_file_name;
    return false;
  }
}
and here is my call stack when violation happened

Code: Select all

CORE_RL_Magick++_.dll!5ddd468a()
CORE_RL_Magick++_.dll!5ddcad27() 	
>	msvcp100d.dll!std::endl(std::basic_ostream<char,std::char_traits<char> > & _Ostr={...})  line  1013	C++
 	msvcp100d.dll!std::basic_ostream<char,std::char_traits<char> >::operator<<(std::basic_ostream<char,std::char_traits<char> > & (std::basic_ostream<char,std::char_traits<char> > &)* _Pfn=0x0017eb0c)  line  189 + 0x7 bytes 	C++
 	lib.exe!libpmk_features::ImageLoader::LoadImage(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & filename="4.jpg", Magick::Image * out_image=0x0017e8cc, std::basic_string<char,std::char_traits<char>,std::allocator<char> > * out_filename=0x0017e8a4 "")  line  48 + 0xf bytes 	C++
 	lib.exe!libpmk_features::ImageDetector::DetectInterestPoints(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & image_filename="4.jpg", std::vector<libpmk_features::InterestPoint,std::allocator<libpmk_features::InterestPoint> > * out_points=0x0017e938 [0]())  line 32 + 0x17 bytes 	C++
 	lib.exe!create_psl(int num_files=2, std::basic_string<char,std::char_traits<char>,std::allocator<char> > * point=0x0017eaec "output.psl")  line 155	C++
 	lib.exe!main()  line 190 + 0x10 line 	C++
 	lib.exe!__tmainCRTStartup()  LINE 555 + 0x19 BYTES	C
 	lib.exe!mainCRTStartup()  line 371	C
 	kernel32.dll!76ed4911() 	
 	ntdll.dll!7732e4b6() 	
 	ntdll.dll!7732e489() 	

FYI : the version i use is ImageMagick-6.6.8-3-Q16-windows-dll
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: access violation problems of ImageLoader::LoadImage()

Post by magick »

You most likely do not have your Visual C++ project set up properly. Go to c:\Program Files\ImageMagick-6.6.8-3-Q16\Magick++_demos and click on the Button project. Build and run. Most likely it will run without complaint. Now use the Button project as the template for your own custom code.
Post Reply