I'm no expert, was just looking for a distraction from my work. You could very very easily be right. :)
On Mon, Sep 9, 2013 at 12:04 PM, Ramiro Pereira de Magalhães < [email protected]> wrote: > Kevin, > > about the m_max_val in pnminput.cpp, it does not to be a long. In fact it > could even be an unsigned short. If I did understand the code, m_max_val is > the maximum value admissible to a pixel in the PGM file. > > > 2013/9/9 Kevin Brightwell <[email protected]> > >> First question, might be stupid, but are you compiling in 64-bit? 32-bit >> will definitely crash, and unreliably do so. >> >> Second, in a bit of PD, I think this might have something to do with it: >> >> private: >> std::ifstream m_file; >> std::string m_current_line; ///< Buffer the image pixels >> const char * m_pos; >> unsigned int m_pnm_type, m_max_val; // shouldn't this be long? >> >> >> bool read_file_scanline (void * data); >> bool read_file_header (); >> }; >> >> >> and this shows up here: >> >> Line 267: >> if (m_max_val > std::numeric_limits<unsigned char>::max()) >> raw_to_raw ((unsigned short *)&buf[0], (unsigned short *) >> data, >> nsamples, (unsigned short)m_max_val); >> else >> raw_to_raw ((unsigned char *)&buf[0], (unsigned char *) >> data, >> nsamples, (unsigned char)m_max_val); // >> casting to a char? >> break; >> >> Lots of places show up that could cause problems with massive file sizes. >> I'm no expert. >> >> Kevin >> >> >> On Mon, Sep 9, 2013 at 11:16 AM, Ramiro Pereira de Magalhães < >> [email protected]> wrote: >> >>> Hi, >>> >>> I have just learned about OIIO and I wrote a simple program with >>> OpenImageIO to load a 10GB PGM file into memory. To try things out I wrote >>> a simple program to load a 10GB PGM (yeah, PGM) file into memory. Sadly, >>> the program crashes prior to completing its task with a Segmentation Fault. >>> The machine where this is running has 64GB RAM, most of it free. Can anyone >>> help me figure out this issue? >>> >>> Bellow is the program I wrote. It is pretty simple: load the image given >>> as argument to it into a buffer, then close the file, clean the buffers and >>> leave. >>> >>> ================CODE================ >>> #include <iostream> >>> #include <string> >>> #include <sstream> >>> #include <OpenImageIO/imageio.h> >>> >>> OIIO_NAMESPACE_USING >>> >>> int main(int argc, char* args[]) >>> { >>> if (argc != 2) >>> { >>> return 1; >>> } >>> const std::string filePath = args[1]; >>> >>> ImageInput *in = ImageInput::open (filePath); >>> const ImageSpec & spec = in->spec(); >>> const int size = spec.width * spec.height; >>> >>> unsigned char * pixels = new unsigned char[size]; >>> in->read_image(TypeDesc::UCHAR, pixels); >>> std::cout << "Done reading." << std::endl; >>> in->close(); >>> std::cout << "Closed file." << std::endl; >>> >>> delete in; >>> delete pixels; >>> >>> std::cout << "Outta here." << std::endl; >>> return 0; >>> } >>> ================CODE================ >>> >>> >>> Segfault happens at line 173 of onminput.cpp. Here is the call stack >>> given by Qt Builder: >>> >>> 0 OpenImageIO::v1_3::raw_to_raw<unsigned char> pnminput.cpp >>> 173 0x7ffff798c1e6 >>> 1 OpenImageIO::v1_3::PNMInput::read_file_scanline pnminput.cpp >>> 272 0x7ffff798b09c >>> 2 OpenImageIO::v1_3::PNMInput::read_native_scanline >>> pnminput.cpp 385 0x7ffff798b91e >>> 3 OpenImageIO::v1_3::ImageInput::read_native_scanlines >>> imageinput.cpp 260 0x7ffff76d9280 >>> 4 OpenImageIO::v1_3::ImageInput::read_scanlines imageinput.cpp >>> 197 0x7ffff76d8c24 >>> 5 OpenImageIO::v1_3::ImageInput::read_scanlines imageinput.cpp >>> 165 0x7ffff76d8977 >>> 6 OpenImageIO::v1_3::ImageInput::read_image imageinput.cpp >>> 631 0x7ffff76db3c8 >>> 7 main show.cpp 31 0x4012b7 >>> >>> >>> I compiled OIIO from the git commit >>> d64b9ac8a63261040ae0263b0709924d8fecf4df (Tue Sep 3 12:53:12 2013 -0700). >>> >>> I appreciate any help. >>> >>> _______________________________________________ >>> Oiio-dev mailing list >>> [email protected] >>> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org >>> >>> >> >> >> -- >> Kevin Brightwell >> *BESc. and BSc. Candidate 2015* >> Western University www.westernu.ca <http://www.uwo.ca> >> e. [email protected] c. 226.678.4927 >> >> _______________________________________________ >> Oiio-dev mailing list >> [email protected] >> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org >> >> > > _______________________________________________ > Oiio-dev mailing list > [email protected] > http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org > > -- Kevin Brightwell *BESc. and BSc. Candidate 2015* Western University www.westernu.ca <http://www.uwo.ca> e. [email protected] c. 226.678.4927
_______________________________________________ Oiio-dev mailing list [email protected] http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
