Crash using button.gadget+bitmap.image

This forum is for general developer support questions.
User avatar
javierdlr
Beta Tester
Beta Tester
Posts: 389
Joined: Sun Jun 19, 2011 10:13 pm
Location: Donostia (GUIPUZCOA) - Spain
Contact:

Crash using button.gadget+bitmap.image

Post by javierdlr »

Hi, I having a GR/crahs when trying to (re)load an image on a bitmap.image object, waht I do/have is:
GUI:

Code: Select all

...
          LAYOUT_AddChild, OBJ(OID_PREVIEW_BTN) = IIntuition->NewObject(ButtonClass, NULL, //"button.gadget",
            GA_ID,         OID_PREVIEW_BTN,
            GA_RelVerify,  TRUE,
            GA_Underscore, 0,
            //GA_Text,       "",
            BUTTON_BevelStyle,  BVS_THIN,
            BUTTON_Transparent, TRUE,
            BUTTON_RenderImage, OBJ(OID_PREVIEW_IMG) = IIntuition->NewObject(BitMapClass, NULL, //"bitmap.image",
             //BITMAP_SourceFile, ROMS"Previews/availablepreview.png",
             BITMAP_Screen,     screen,
             BITMAP_Masking,    TRUE,
            TAG_DONE),
           TAG_DONE),
           CHILD_MaxWidth,  256, // pixels width of preview
           CHILD_MaxHeight, 224, // pixels height of preview
          TAG_DONE),
...
It just shows an empty 256x224 button, ok, but when I click on a listbrowser's entry it (re)loads another image, then I do:

Code: Select all

...
	Object *oldobj = OBJ(OID_PREVIEW_IMG);
['filename' has the fullpath of the new PNG image, choosen/clicked in listbrowser]
	// Create/set new preview (, dispose old), "reassign" new and refresh window/pagetab
	OBJ(OID_PREVIEW_IMG) = IIntuition->NewObject(BitMapClass, NULL, //"bitmap.image",
			                         BITMAP_Masking,TRUE, BITMAP_Screen,pw->WScreen,//screen,
			                         BITMAP_SourceFile,filename, TAG_DONE);
//	if( OBJ(OID_PREVIEW_IMG) ) {
//	  ILayout->SetPageGadgetAttrs(GAD(OID_PREVIEW_BTN), OBJ(OID_GENERAL), pw, NULL, BUTTON_RenderImage,OBJ(OID_PREVIEW_IMG), TAG_DONE); // pagetab
//	  ILayout->RefreshPageGadget(GAD(OID_PREVIEW_BTN), OBJ(OID_GENERAL), pw, NULL);
	    IIntuition->DisposeObject(oldobj);
//	}
...
The crash just happens right after 'OBJ(OID_PREVIEW_IMG) = IIntuition->NewObject(..' that's where crashlog points to [snes9xgui.c:511]

Code: Select all

odlobj: 0x591C5834
[HAL_Alert] ALERT! 0x80000003, IP = 0x01AB651C
[_impl_CacheClearU] *** Warning: CacheClearU is deprecated
Dump of context at 0xFFBB1000
Trap type: DSI exception
Machine State (raw): 0x0002F030
Machine State (verbose): [ExtInt on] [User] [FPU on] [IAT on] [DAT on] 
Instruction pointer: in module Kickstart/intuition.library.kmod+0x00005ABC (0x01AB651C)
Crashed process: snes9xGUI.debug (0x5A97C1A0)
 0: 01AB6514 58986180 00000000 0218972C 6FF5F542 24260000 589862B8 591C5744
 8: 591C57AC 02350000 00000000 00000007 28822484 5961F690 00000000 00000000
16: 00000000 81547402 8154740A 28822888 00000000 81547401 8154740D 00000000
24: 591C5438 24260000 6FF5E4D0 00000000 8154740B 00000000 81547403 81547407
CR: 28442888   XER: 00000001  CTR: 01822B14  LR: 01AB6514
ESR: 00000000
DEAR: 24260058
mcsrr0: 0x00000000
csrr0: 0x00000000

Disassembly of crash site:
 01AB650C: 7D2903A6   mtctr             r9
 01AB6510: 4E800421   bctrl             
 01AB6514: 418E01F4   beq-              cr3,0x1AB6708
 01AB6518: 3D200235   lis               r9,565
>01AB651C: 80990058   lwz               r4,88(r25)
 01AB6520: 38A00013   li                r5,19
 01AB6524: 8169B5EC   lwz               r11,-18964(r9)
 01AB6528: 812B1156   lwz               r9,4438(r11)
 01AB652C: 7D234B78   mr                r3,r9
 01AB6530: 812902CC   lwz               r9,716(r9)
..
Kernel command line: debuglevel=4 SERIAL

Registers pointing to code:
r0 : native kernel module Kickstart/intuition.library.kmod+0x00005ab4
r3 : native kernel module Kickstart/kernel.debug+0x0098972c
ip : native kernel module Kickstart/intuition.library.kmod+0x00005abc
lr : native kernel module Kickstart/intuition.library.kmod+0x00005ab4
ctr: native kernel module Kickstart/kernel.debug+0x00022b14

Stack trace:
(0x58986180) native kernel module Kickstart/intuition.library.kmod+0x00005abc
(0x58986240) native kernel module Kickstart/intuition.library.kmod+0x00005ab4
(0x589862B0) module CLASSES:images/bitmap.image at 0x7FD8E3EC (section 0 @ 0x33C8)
(0x589864A0) native kernel module Kickstart/intuition.library.kmod+0x00021448
(0x58986500) native kernel module Kickstart/intuition.library.kmod+0x000215ec
(0x58986580) native kernel module Kickstart/intuition.library.kmod+0x0000a348
(0x589865B0) native kernel module Kickstart/intuition.library.kmod+0x0000a0dc
(0x58986620) [snes9xgui.c:511] snes9xGUI.debug:LaunchShowRom()+0x7c8 (section 1 @ 0x2EB8)
(0x58986680) [gui.c:307] snes9xGUI.debug:ProcessGUI()+0x1014 (section 1 @ 0x4C84)
(0x58986700) [gui.c:998] snes9xGUI.debug:CreateGUIwindow()+0x47f4 (section 1 @ 0x991C)
(0x58986BC0) [snes9xgui.c:236] snes9xGUI.debug:main()+0x57c (section 1 @ 0x14B0)
(0x58986D00) native kernel module Kickstart/newlib.library.kmod+0x000020ac
(0x58986D70) native kernel module Kickstart/newlib.library.kmod+0x00002d5c
(0x58986F10) native kernel module Kickstart/newlib.library.kmod+0x00002ef0
(0x58986F50) snes9xGUI.debug:_start()+0x170 (section 1 @ 0x16C)
(0x58986F90) native kernel module Kickstart/dos.library.kmod+0x000261f8
(0x58986FC0) native kernel module Kickstart/kernel.debug+0x00067bc4
(0x58986FD0) native kernel module Kickstart/kernel.debug+0x00067c0c
...
Any ideas what I'm doing wrong?
As you can see in code I don't "show"/paint image (it's commented) to try to find problem/culprit.
And it doesn't happen always it just happens after a couple iconify/uniconify actions and when (re)selecting a new lb's entry.
User avatar
Rigo
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 360
Joined: Mon Jan 17, 2011 9:42 pm

Re: Crash using button.gadget+bitmap.image

Post by Rigo »

Can you generate a small program to reproduce the problem?

Looking at your code, and the crashlog really doesn't give any context.

Simon
User avatar
javierdlr
Beta Tester
Beta Tester
Posts: 389
Joined: Sun Jun 19, 2011 10:13 pm
Location: Donostia (GUIPUZCOA) - Spain
Contact:

Re: Crash using button.gadget+bitmap.image

Post by javierdlr »

Rigo wrote:Can you generate a small program to reproduce the problem?

Looking at your code, and the crashlog really doesn't give any context.

Simon
I can provide full source code, its snex9xGUI (alternative GUI to HunoPPC's one) http://jabirulo.site90.com/temp/snes9xgui.lha

It happens when iconify/uniconify and clicking on listbrowser entries. It always crashes at same place [snes9xgui.c], tried several ways of creating/set/refresh such object:

Code: Select all

// Create/set new preview, refresh button/preview and dispose old
			newobj = IIntuition->NewObject(BitMapClass, NULL, //"bitmap.image",
			                                             BITMAP_Masking,TRUE, BITMAP_Screen,pw->WScreen,//screen,
			                                             BITMAP_SourceFile,filename, TAG_DONE);
And always at same line, and GR/crash points to inutition.library. Will try to create a minimal GUI with only listbrowser and button+image and see what happens.

EDIT1: Here is a minimal GUI with only listbrowser and button+image: http://jabirulo.site90.com/temp/snes9xguiMINIMAL.lha just removed in gui.c all "extra" stuff, rest of sources are like "normal" snex9xgui.lha
Instead of iconify/uniconify you can click on preview button (now empty) as it does a CLOSE/OPEN window in MINIMAL version (just commented launch of ROM)

EDIT2: if I comment 'newobj = IIntuition->NewObject(...' I don't get such crash (or maybe I'm "delaying" it), but I can't reproduce it then.
User avatar
javierdlr
Beta Tester
Beta Tester
Posts: 389
Joined: Sun Jun 19, 2011 10:13 pm
Location: Donostia (GUIPUZCOA) - Spain
Contact:

Re: Crash using button.gadget+bitmap.image

Post by javierdlr »

Try this updated imagebut.c (from ReAction examples in os4depot IIRC) http://jabirulo.site90.com/temp/imagebut.lha when you click on the phantom image the upper button changes from selected<->unselected. Does not crash ¿:-P

Maybe is 'cos I'm using page/tabs on snes9xgui?
EDIT1: nop, still having the crash:

Code: Select all

[HAL_Alert] ALERT! 0x80000003, IP = 0x01AB651C
[_impl_CacheClearU] *** Warning: CacheClearU is deprecated
Dump of context at 0xFFA14BA0
Trap type: DSI exception
Machine State (raw): 0x0002F030
Machine State (verbose): [ExtInt on] [User] [FPU on] [IAT on] [DAT on] 
Instruction pointer: in module Kickstart/intuition.library.kmod+0x00005ABC (0x01AB651C)
Crashed process: snes9xGUI.debug (0x56FF9500)
 0: 01AB6514 5E379500 00000000 0218972C 6FF5F542 24260000 5E379638 00000000
 8: 5F7F91A4 02350000 00000000 00000007 22824284 58296990 00000000 00000000
16: 00000000 81547402 8154740A 22824888 00000000 81547401 8154740D 00000000
24: 5F7F8668 24260000 6FF5E4D0 00000000 8154740B 00000020 81547403 81547407
CR: 22444888   XER: 20000002  CTR: 01822B14  LR: 01AB6514
ESR: 00000000
DEAR: 24260058
mcsrr0: 0x00000000
csrr0: 0x00000000
..

Kernel command line: debuglevel=4 MUNGE SERIAL

Registers pointing to code:
r0 : native kernel module Kickstart/intuition.library.kmod+0x00005ab4
r3 : native kernel module Kickstart/kernel.debug+0x0098972c
ip : native kernel module Kickstart/intuition.library.kmod+0x00005abc
lr : native kernel module Kickstart/intuition.library.kmod+0x00005ab4
ctr: native kernel module Kickstart/kernel.debug+0x00022b14

Stack trace:
(0x5E379500) native kernel module Kickstart/intuition.library.kmod+0x00005abc
(0x5E3795C0) native kernel module Kickstart/intuition.library.kmod+0x00005ab4
(0x5E379630) module CLASSES:images/bitmap.image at 0x7FD833EC (section 0 @ 0x33C8)
(0x5E379820) native kernel module Kickstart/intuition.library.kmod+0x00021448
(0x5E379880) native kernel module Kickstart/intuition.library.kmod+0x000215ec
(0x5E379900) native kernel module Kickstart/intuition.library.kmod+0x0000a348
(0x5E379930) native kernel module Kickstart/intuition.library.kmod+0x0000a0dc
(0x5E3799A0) [snes9xgui.c:513] snes9xGUI.debug:LaunchShowRom()+0x7e8 (section 1 @ 0x2ED8)
(0x5E379A20) [gui.c:172] snes9xGUI.debug:ProcessGUI()+0x408 (section 1 @ 0x4478)
(0x5E379A80) [gui.c:349] snes9xGUI.debug:CreateGUIwindow()+0xf4c (section 1 @ 0x5448)
(0x5E379BC0) [snes9xgui.c:236] snes9xGUI.debug:main()+0x57c (section 1 @ 0x14B0)
(0x5E379D00) native kernel module Kickstart/newlib.library.kmod+0x000020ac
(0x5E379D70) native kernel module Kickstart/newlib.library.kmod+0x00002d5c
(0x5E379F10) native kernel module Kickstart/newlib.library.kmod+0x00002ef0
(0x5E379F50) snes9xGUI.debug:_start()+0x170 (section 1 @ 0x16C)
(0x5E379F90) native kernel module Kickstart/dos.library.kmod+0x000261f8
(0x5E379FC0) native kernel module Kickstart/kernel.debug+0x00067bc4
(0x5E379FD0) native kernel module Kickstart/kernel.debug+0x00067c0c
..
EDIT2: can the crash/GR be 'cos some of the preview image filenames have "special" characters (like '!' '(' ')' ...)?
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: Crash using button.gadget+bitmap.image

Post by xenic »

javierdlr wrote:EDIT2: can the crash/GR be 'cos some of the preview image filenames have "special" characters (like '!' '(' ')' ...)?
I tried to test your normal (not minimize) code by downloading & extracting the snes9x.zip archive, compiling your code and copying the snes9xGUI binary to the Snes9X-OS4 directory, adding an icon to snes9xGUI and launching snes9xGUI with a double-click on the icon. A console pops up with some debug data and shows the preview name like this:

ROM preview: 'PROGDIR:Previews/LzKÀ{N´.PNG'

I don't see any ROMS in the Snes9X-OS4 directory but I don't think the preview name should be junk letters if no ROMs are present. I would need more information to test for the crash you're getting.
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
javierdlr
Beta Tester
Beta Tester
Posts: 389
Joined: Sun Jun 19, 2011 10:13 pm
Location: Donostia (GUIPUZCOA) - Spain
Contact:

Re: Crash using button.gadget+bitmap.image

Post by javierdlr »

xenic wrote:...
ROM preview: 'PROGDIR:Previews/LzKÀ{N´.PNG'

I don't see any ROMS in the Snes9X-OS4 directory but I don't think the preview name should be junk letters if no ROMs are present. I would need more information to test for the crash you're getting.
Confimed, thx. Try this updated version http://jabirulo.site90.com/temp/snes9xgui.lha

My problem is when iconify/uniconify and the clicking on entries on the listbrowser.
1)start snes9xgui and click on a rom entry in the listbrowser.
2)iconify snes9xgui
3)uniconify snes9xgui
4)click another entry on listbrowser, try another (so a few times)
5)Go to step 2)
It doesn't happens always, you must do steps 2)...4) a few times and then (at last here) it crashes/GR.
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: Crash using button.gadget+bitmap.image

Post by xenic »

javierdlr wrote:Confimed, thx. Try this updated version http://jabirulo.site90.com/temp/snes9xgui.lha
Your updated version has the crashing line commented out like this:

// Create/set new preview, refresh button/preview and dispose old
// newobj = IIntuition->NewObject(BitMapClass, NULL, //"bitmap.image",
// BITMAP_Masking,TRUE, BITMAP_Screen,pw->WScreen,//screen,
// BITMAP_SourceFile,filename, TAG_DONE);

How could anyone test for the crash if the offending code is commented out??

It looks like the code reads ROM names, replaces the extension with a "PNG" extension and then finds the preview image in the Previews directory. There are no ROMS in the Snes9x emulator at OS4Depot so the lister in your program is always empty. Unless I've misunderstood the code, there is no way I can test your code without any ROMS. Sorry.
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
javierdlr
Beta Tester
Beta Tester
Posts: 389
Joined: Sun Jun 19, 2011 10:13 pm
Location: Donostia (GUIPUZCOA) - Spain
Contact:

Re: Crash using button.gadget+bitmap.image

Post by javierdlr »

xenic wrote:
javierdlr wrote:Confimed, thx. Try this updated version http://jabirulo.site90.com/temp/snes9xgui.lha
Your updated version has the crashing line commented out like this:

// Create/set new preview, refresh button/preview and dispose old
// newobj = IIntuition->NewObject(BitMapClass, NULL, //"bitmap.image",
// BITMAP_Masking,TRUE, BITMAP_Screen,pw->WScreen,//screen,
// BITMAP_SourceFile,filename, TAG_DONE);

How could anyone test for the crash if the offending code is commented out??

It looks like the code reads ROM names, replaces the extension with a "PNG" extension and then finds the preview image in the Previews directory. There are no ROMS in the Snes9x emulator at OS4Depot so the lister in your program is always empty. Unless I've misunderstood the code, there is no way I can test your code without any ROMS. Sorry.
Ooops, forget to uncomment the part of cade that crashes (as I'm testing different aproaches to see if I can fix such problem/bug). And yes what it does, it gets the rom filename adds .PNG and loads such file (if exists).

You con get snes roms on the net https://duckduckgo.com/?q=snes9x+roms
http://www.emuparadise.me/Super_Nintend ... ES)_ROMs/5
if you want give me your email (mine is jabierdlrATgmailDOTcom) and can send you a couple of roms to test it.
THX for helping.
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: Crash using button.gadget+bitmap.image

Post by xenic »

javierdlr wrote: Ooops, forget to uncomment the part of cade that crashes (as I'm testing different aproaches to see if I can fix such problem/bug). And yes what it does, it gets the rom filename adds .PNG and loads such file (if exists).
I downloaded 6 ROMS and tested binaries compiled from both source archives you posted and get no crashes. I iconified, uniconified, selected a different ROM from the list and repeated the iconify/uniconify at least 20 times. I tested with the stripped version of the binaries; not the debug versions.

As you can see in my tagline, I'm using an X1000. If you are using different hardware that may make a difference. I compiled your sources with the latest SDK from the Hyperion WEB site. If you are cross-compiling or using GCC 5.x that might make a difference. Sorry I can't help.
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
javierdlr
Beta Tester
Beta Tester
Posts: 389
Joined: Sun Jun 19, 2011 10:13 pm
Location: Donostia (GUIPUZCOA) - Spain
Contact:

Re: Crash using button.gadget+bitmap.image

Post by javierdlr »

xenic wrote:...
I downloaded 6 ROMS and tested binaries compiled from both source archives you posted and get no crashes. I iconified, uniconified, selected a different ROM from the list and repeated the iconify/uniconify at least 20 times. I tested with the stripped version of the binaries; not the debug versions.

As you can see in my tagline, I'm using an X1000. If you are using different hardware that may make a difference. I compiled your sources with the latest SDK from the Hyperion WEB site. If you are cross-compiling or using GCC 5.x that might make a difference. Sorry I can't help.
THX for tests. My system is a SAM460ex, ussign GCC:

Code: Select all

#gcc -v
Using built-in specs.
Target: ppc-amigaos
Configured with: ../gcc/configure --prefix=/gcc --host=ppc-amigaos --target=ppc-amigaos --build=i686-cygwin --enable-haifa --enable-sjlj-exceptions --enable-languages=c,c++
Thread model: single
gcc version 4.2.4 (adtools build 20090118)
Maybe is a filesystem/timing issue ¿:-/
Post Reply