ColinPitrat / caprice32

An emulator of the Amstrad CPC 8bit home computer range.
GNU General Public License v2.0
148 stars 32 forks source link

Bicubic filter causes segfault #159

Closed tbigot closed 4 years ago

tbigot commented 4 years ago

Just compiled caprice32 from git.

Choosing bicubic in the parameters cause the app to systematically segfault, even at startup (setting saved). Here is the backtrace:

Thread 1 "cap32" received signal SIGSEGV, Segmentation fault.
0x00000000004bc12d in filter_bicubic (srcPtr=0x680d40 "", srcPitch=768, dstPtr=0x7ffff58d2010 "", dstPitch=1536, width=384, height=266) at src/video.cpp:1618
1618              MULT(*pIn, &r, &g, &b, r1 * r2);
(gdb) bt
#0  0x00000000004bc12d in filter_bicubic (srcPtr=0x680d40 "", srcPitch=768, dstPtr=0x7ffff58d2010 "", dstPitch=1536, width=384, height=266) at src/video.cpp:1618
#1  0x00000000004bc5e9 in swbicub_flip () at src/video.cpp:1690
#2  0x000000000041364c in video_display () at src/cap32.cpp:1481
#3  0x000000000041d264 in cap32_main (argc=1, argv=0x7fffffffd978) at src/cap32.cpp:2311
#4  0x00000000004ebce3 in main (argc=1, argv=0x7fffffffd978) at main.cpp:5
ColinPitrat commented 4 years ago

Reproduced both on the latest version and the first version checked in. I tested with X color depth being 32 bpp. I don't think this should be the issue, but I'd like to test with 16bpp just to be sure, as the bicubic video driver is forcing 16bpp (but it's not the only one and the others are working fine).

ColinPitrat commented 4 years ago

I think the problem is that the first pixel that is read is just 2 bytes before the beginning of the video surface. This is because a one line offset is passed but not a one column offset when calling filter_bicubic: static_cast<Uint8>(pub->pixels) + (2src.x+src.y*pub->pitch) + (pub->pitch)

ColinPitrat commented 4 years ago

Fixed, but the filter suffers from bad performances. I opened #160 to track this.