Loading a png with devIL

Post: #1
Hey everyone! This is my first post on these forums, but I check around these parts quite often.

My name is Corey, and I am currently a developer for the independent project called "Hero of Allacrost." I am trying to get the application working for MacOSX, and am running into problems.

Everytime the program boots and tries to load DevIL, I get an EXC_BAD_ACCESS on eadpng_get_image, called from iLoadPngInternal. DevIL loads any other format fine, however. I posted this on the DevIL help forums on September 9, 2005. I never got a response. So after trying to solve it by myself sporadically, I am turning elsewhere for else.

So I am wondering if you guys have any idea as to what the issue could be. I heard there are issues with libpng with anything else but 24 depth and true color...but thats exactly what the images are.

Is it possible that my libpng is corrupted some how? I have tried to install it several times, but perhaps I am doing something wrong? Does anyone have a version they know works?

Do you guys have any ideas as to what could be going on?

Thanks a lot!
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #2
(r?)eadpng_get_image is not a part of libpng, so it's a little unlikely that libpng is at fault for a crash there. However, there is a function called readpng_get_image in the example code that comes with libpng...

I'm not aware of any bugs in libpng.

I'd suggest taking a debugger to the thing. Figure out precisely what's crashing where, and why.
Quote this message in a reply
Posts: 834
Joined: 2002.09
Post: #3
To expand on that: Hit Cmd-Y while in XCode to run the debugger.
Quote this message in a reply
Post: #4
Well, I did the debugging to get that info, but here is some more.Basically, the hierarchy of functions goes like this,


It crashes on the last readpng_get_image. Anything prefixed with i is a devIL method. Here is the data from within readpng_get_image:

width: 0
height: 25467672
screen_gamma: 0
image_gama: 1.0808468306
i: 3221215504
channels: 25466388
bit_depth: 0

This data looks more uninitialized than read incorrectly from the png.

Anyone have any more ideas where to poke around for the answer?

Thanks for the help so far!
Quote this message in a reply
Post: #5
Okay. I did a bit of testing, and it doesn't seem that there is anything wrong on my side of the code (endianess, et cetera). I ran a test program that crashed in the same spot:

#include <iostream>

#include <OpenGL/gl.h>

#include <IL/il.h>
#include <IL/ilu.h>
#include <IL/ilut.h>

int main (int argc, char * const argv[]) {
        ILuint ImageName;
        ilGenImages(1, &ImageName);
        if(ilLoadImage("test.png")) {
           std::cout << "Success." << std::endl;
        ILuint Width, Height;
        Width = ilGetInteger(IL_IMAGE_WIDTH);
        Height = ilGetInteger(IL_IMAGE_HEIGHT);
        ILubyte *Data = ilGetData();
        ilDeleteImages(1, &ImageName);
        return 0;

That crashed the same way, so I think it definitely has to do with devIL -- most likely something being sent wrong to libpng.

Looking into the crash log, I see that the last line is:
warning: Previous frame identical to this frame (corrupt stack?)

Digging a little deeper, I find this:

#1  0x01849d3c in readpng_get_image (display_exponent=1) at /Users/dario/Desktop/Developer/Projects/DevIL/cvsroot/DevIL/src-IL/src/il_png.c:295
295    /Users/dario/Desktop/Developer/Projects/DevIL/cvsroot/DevIL/src-IL/src/il_png.c: No such file or directory.
    in /Users/dario/Desktop/Developer/Projects/DevIL/cvsroot/DevIL/src-IL/src/il_png.c
(gdb) up
#2  0x01849920 in iLoadPngInternal () at /Users/dario/Desktop/Developer/Projects/DevIL/cvsroot/DevIL/src-IL/src/il_png.c:169
169    in /Users/dario/Desktop/Developer/Projects/DevIL/cvsroot/DevIL/src-IL/src/il_png.c

Seems to be having an issue finding a file that it found the previous frame, which I find totally wierd.


Since I seem to be getting nowhere with this, would anyone else be willing to try to build and test it?
Quote this message in a reply
Post Reply