Devil segfault, problems with png, bmp

I am in mingw (gcc version 4.5.2).

I get segfault when opening certain files, including PNG and BMP. It worked fine on PNG 128x128, but when I started testing files with large files, I started getting segfault. However, there are no problems with the TGA format. I know that the library works for the most part, but not knowing if it decides to crash and burn, this is not good.

gdb does not give me any clues about what is going on. I can compile DevIL from the source, and I compiled the dll debug ( --enable-debug for configure script), but it doesn't seem to support png (I think I need to get the png12 library), but it isnโ€™t "I'm very far.

I am trying to open a 2 MB BMP that I made in GIMP. I run it through GDB and sometimes it will be segfault, but in other cases it warns about some things happening on the heap (a lot of things that I have never seen before). This is where the gdb dump starts. All lines starting with %%% are output specific to my program, the rest are from gdb.

 $ gdb ./entropy_unittest_disp.exe loadpngdisplay GNU gdb (GDB) 7.2 Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "mingw32". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from c:\Users\Steven\Dropbox\Programming\entropy_p5_makefile\cpp \game/./entropy_unittest_disp.exe...done. c:\Users\Steven\Dropbox\Programming\entropy_p5_makefile\cpp\game/loadpngdisplay: No such file or directory. (gdb) r Starting program: c:\Users\Steven\Dropbox\Programming\entropy_p5_makefile\cpp\ga me/./entropy_unittest_disp.exe [New Thread 23284.0x5bb4] %%%UNIT TEST BUILD: INTERNAL USE ONLY. DO NOT DISTRIBUTE %%%Compiled on Sep 11 2011 at 09:45:38 %%%argc = 1: Main.cpp:119 %%%argv: %%%0: c:\Users\Steven\Dropbox\Programming\entropy_p5_makefile\cpp\game/./entropy_un %%%ittest_disp.exe %%%โ†[36mStarting Test ilWritePng, at Image.cpp:8โ†[0m %%%rm: cannot lstat `output_il.png': No such file or directory %%%ilGetError() = 1292: Image.cpp:25 %%%Completed Test ilWritePng in 0.033 seconds %%%โ†[36mStarting Test loadPNGDisplay, at Image.cpp:31โ†[0m [New Thread 23284.0x445c] [New Thread 23284.0x1fd8] [New Thread 23284.0x1424] %%%Number of Joysticks detected: 2 %%%Opening Joystick: Harmonix Guitar for Xbox 360 (Controller) [New Thread 23284.0x526c] [New Thread 23284.0x5a70] [New Thread 23284.0x1ae8] [New Thread 23284.0x5908] [New Thread 23284.0x5974] %%%Using GLEW 1.5.8 %%%OpenGL Vendor: NVIDIA Corporation %%%OpenGL Renderer: GeForce GTX 260/PCI/SSE2 %%%OpenGL Version: 3.3.0 warning: HEAP[entropy_unittest_disp.exe]: warning: Invalid address specified to RtlFreeHeap( 00350000, 04000000 ) Program received signal SIGTRAP, Trace/breakpoint trap. 0x772e0475 in ntdll!TpWaitForAlpcCompletion () from C:\Windows\system32\ntdll.dll (gdb) where #0 0x772e0475 in ntdll!TpWaitForAlpcCompletion () from C:\Windows\system32\ntdll.dll #1 0x0028f510 in ?? () #2 0x772a29c0 in ntdll!RtlCopyExtendedContext () from C:\Windows\system32\ntdll.dll #3 0x03fffff8 in ?? () #4 0x772e14cf in ntdll!TpQueryPoolStackInformation () from C:\Windows\system32\ntdll.dll #5 0x00350000 in ?? () #6 0x7729ab3a in ntdll!AlpcMaxAllowedMessageLength () from C:\Windows\system32\ntdll.dll #7 0x00350000 in ?? () #8 0x77243472 in ntdll!RtlLargeIntegerShiftRight () from C:\Windows\system32\ntdll.dll #9 0x03fffff8 in ?? () #10 0x766398cd in msvcrt!free () from C:\Windows\syswow64\msvcrt.dll #11 0x00350000 in ?? () #12 0x6180129c in _mm_free (aligned_ptr=0x8230020) at c:/mingw/bin/../lib/gcc/mingw32/4.5.2/include/mm_malloc.h:71 #13 0x61801370 in DefaultFreeFunc (ptr=0x8230020) at ./../src-IL/src/il_alloc.c:127 #14 0x618012ee in ifree (Ptr=0x8230020) at ./../src-IL/src/il_alloc.c:99 #15 0x618149f8 in iPreCache (Size=592128) at ./../src-IL/src/il_files.c:550 #16 0x618148a2 in iReadFile (Buffer=0x8100017, Size=1, Number=2313) at ./../src-IL/src/il_files.c:499 #17 0x61808cf5 in ilReadUncompBmp (Header=0x28f829) at ./../src-IL/src/il_bmp.c:486 #18 0x61808410 in iLoadBitmapInternal () at ./../src-IL/src/il_bmp.c:250 #19 0x618082f3 in ilLoadBmpF (File=0x766d2960) at ./../src-IL/src/il_bmp.c:199 #20 0x618082ba in ilLoadBmp (FileName=0x4c25f1 "folder.bmp") at ./../src-IL/src/il_bmp.c:184 #21 0x61830bf0 in ilLoadImage (FileName=0x4c25f1 "folder.bmp") at ./../src-IL/src/il_io.c:1827 #22 0x0040f66c in SDLSystemloadPNGDisplayHelper::RunImpl (this=0x28fc10) at Image.cpp:40 #23 0x00461e74 in UnitTest::ExecuteTest<SDLSystemloadPNGDisplayHelper> ( testObject=..., details=...) at ../include/UnitTest++/ExecuteTest.h:25 #24 0x0040f2cd in TestSDLSystemloadPNGDisplay::RunImpl (this=0x4e5cf8) at Image.cpp:31 #25 0x00463023 in UnitTest::ExecuteTest<UnitTest::Test> (testObject=..., details=...) at src/ExecuteTest.h:25 #26 0x0044198d in UnitTest::Test::Run (this=0x4e5cf8) at src/Test.cpp:34 #27 0x00441d9a in UnitTest::TestRunner::RunTest (this=0x28fedc, result=0x3517f0, curTest=0x4e5cf8, maxTestTimeInMs=0) at src/TestRunner.cpp:61 #28 0x00466b7e in UnitTest::TestRunner::RunTestsIf<UnitTest::True> ( this=0x28fedc, list=..., suiteName=0x0, predicate=..., maxTestTimeInMs=0) at ../include/UnitTest++/TestRunner.h:40 #29 0x004014e3 in UnitTest::RunAllTestsVerbose () at Main.cpp:72 #30 0x0040167d in main (argc=1, argv=0x3531d8) at Main.cpp:126 (gdb) c Continuing. warning: HEAP[entropy_unittest_disp.exe]: warning: Invalid address specified to RtlFreeHeap( 00350000, 04000000 ) Program received signal SIGTRAP, Trace/breakpoint trap. 0x772e0475 in ntdll!TpWaitForAlpcCompletion () from C:\Windows\system32\ntdll.dll (gdb) c Continuing. warning: HEAP[entropy_unittest_disp.exe]: warning: Invalid address specified to RtlFreeHeap( 00350000, 04000000 ) Program received signal SIGTRAP, Trace/breakpoint trap. 0x772e0475 in ntdll!TpWaitForAlpcCompletion () from C:\Windows\system32\ntdll.dll (gdb) Continuing. warning: HEAP[entropy_unittest_disp.exe]: warning: Invalid address specified to RtlFreeHeap( 00350000, 04000000 ) Program received signal SIGTRAP, Trace/breakpoint trap. 0x772e0475 in ntdll!TpWaitForAlpcCompletion () from C:\Windows\system32\ntdll.dll (gdb) Continuing. Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 23284.0x5974] 0x05064225 in nvoglv32!DrvGetProcAddress () from C:\Windows\SysWOW64\nvoglv32.dll (gdb) Continuing. Program received signal SIGSEGV, Segmentation fault. 0x05064225 in nvoglv32!DrvGetProcAddress () from C:\Windows\SysWOW64\nvoglv32.dll (gdb) Continuing. Program exited with code 030000000005. (gdb) The program is not being run. (gdb) r Starting program: c:\Users\Steven\Dropbox\Programming\entropy_p5_makefile\cpp\ga me/./entropy_unittest_disp.exe [New Thread 23428.0x49b8] %%%UNIT TEST BUILD: INTERNAL USE ONLY. DO NOT DISTRIBUTE %%%Compiled on Sep 11 2011 at 09:45:38 %%%argc = 1: Main.cpp:119 %%%argv: %%%0: c:\Users\Steven\Dropbox\Programming\entropy_p5_makefile\cpp\game/./entropy_un %%%ittest_disp.exe %%%โ†[36mStarting Test ilWritePng, at Image.cpp:8โ†[0m Program received signal SIGSEGV, Segmentation fault. 0x7723dfc4 in ntdll!LdrWx86FormatVirtualImage () from C:\Windows\system32\ntdll.dll (gdb) where #0 0x7723dfc4 in ntdll!LdrWx86FormatVirtualImage () from C:\Windows\system32\ntdll.dll #1 0x1f002150 in ?? () #2 0x00000000 in ?? () (gdb) 

The ilWritePng test actually just writes the .tga image file. This test works fine with dll release (md5 = 59E291838AE2C88F5F71108E4845A84B), but in this debug build I collected more problems.

I was so happy when I shot the document and got Devil and worked like 10 minutes. I decided that it would save me , so it works a lot ...

This makes me wonder if I should just implement my own image file format (I would use a binary PPM file and drag it through the compression stream).

edit: source code:

 #include "Texture.h" // for Pixel struct #include "Script.h" // for lua (quick and dirty shell access) TEST_FIXTURE(ILSystem, ilWritePng) { // ILSystem calls ilInit(), ilShutDown() in ctor, dtor respectively ILuint image; ilGenImages(1,&image); CHECK(ilGetError()==0); ilBindImage(image); Pixel pixels[128*128]; for (int i=0;i<128;++i) { for (int j=0;j<128;++j) { Pixel &p = pixels[i*128+j]; pb = 0; pg = i; pr = j; pa = 0xff; }} // neat and simple test image, a greenish purplish gradient type thing. CHECK(ilTexImage(128,128,1,4,IL_BGRA, IL_UNSIGNED_BYTE,pixels)); CHECK(ilGetError()==0); { LuaSystem l; l.dostring("os.execute(\"rm output_il.tga\")"); // delete that file } ilSaveImage("output_il.tga"); PRINT_INT(ilGetError()); } #ifdef LOAD_DISPLAY #include "SDLOGL.h" #include "Texture.h" TEST_FIXTURE(SDLSystem, loadPNGDisplay) { // takes care of initing SDL and opengl context ILSystem s; // RAII = peace of mind // i can't use two fixtures in one unittest. but this does the same thing anyway. ILuint image; CHECK(ilGetError()==0); ilGenImages(1,&image); CHECK(ilGetError()==0); ilBindImage(image); CHECK(ilGetError()==0); ilLoadImage("folder.bmp"); CHECK(ilGetError()==0); ILubyte *pixelData = ilGetData(); CHECK(pixelData); CHECK(ilGetError()==0); GLuint tex = loadImage32(pixelData,ilGetInteger(IL_IMAGE_WIDTH),ilGetInteger(IL_IMAGE_HEIGHT),0); // i do not know exactly how its encoded. but it seems like when loading pngs it is in RGBA format PRINT_INT(ilGetInteger(IL_FORMAT_MODE)); CHECK(ilGetError()==0); initOrthoRender(); drawTexture(tex); CHECK(glGetError()==0); SDL_GL_SwapBuffers(); SLEEP(500); } #endif //LOAD_DISPLAY 
0
source share

Source: https://habr.com/ru/post/1394948/


All Articles