Menu

#131 Crash in ilActiveMipmap() when called repeatedly

closed-wont-fix
nobody
None
5
2007-04-09
2007-04-09
No

I'm loading an image (a 128x128 TGA file), running iluBuildMipmaps(), and then iterating over the mip levels from 0 to ilGetInteger(IL_NUM_MIPMAPS) calling ilActiveMipmap() on each level. The number of levels is 7 (which seems correct), but when my loop gets to ilActiveMipmap(2), it crashes.

I took a look at the code in il_stack.c, and I think I see what the problem is. It looks like the function is written with the assumption that when it's called, the current image is the base-level mipmap. For an example of this, notice that the function always returns immediately if the requested mip level is 0; that wouldn't be correct if you've already called ilActiveMipmap() to select a different mip level.

Similarly, I suspect that the crash I'm seeing is caused by this same assumption. When I call with mip level 0, it returns immediately. When I call with mip level 1, it correctly sets mip level 1. When I then call with mip level 2, the function attempts to access iCurImage->Mipmaps (and later, iCurImage->Mipmaps->next). I have a sneaking suspicion that iCurImage->Mipmaps is only non-NULL when iCurImage points to the base-level mipmap, and that this is what's causing my crash.

In either case, I think the problem can be fixed by adding some code at the top of the function that resets iCurImage to the base mip level. I also noticed that ilActiveLayer and ilActiveImage() seem to be written very similarly, and may have similar bugs.

Let me know if I'm totally off track or if you're unable to reproduce the problem; I can provide a short sample program if necessary. Thanks!

Discussion

  • Anonymous

    Anonymous - 2007-04-09

    Logged In: YES
    user_id=710897
    Originator: NO

    We are aware of the 'problem'. It has been like this for long and this behaviour is planned to change in a new big revision of DevIL, we can't change this now for compatibility

     
  • Anonymous

    Anonymous - 2007-04-09
    • status: open --> closed-wont-fix
     
  • Anonymous

    Anonymous - 2007-04-09

    Logged In: YES
    user_id=30947
    Originator: YES

    Okay, that's fine; it seems I can work around the problem by unbinding and rebinding the image between calls to ilActiveMipmap(). Glad to hear the project is still under development!

     

Log in to post a comment.