How many bits per pixel does this file have? If you have just 1 bit of
data per pixel and read it as an unsigned char, that will give you a
80 GB buffer. If that's the case the workaround would be to read and
convert to 1 bit per pixel per scanline.

On Mon, Sep 9, 2013 at 5:16 PM, 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
>
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to