Hi, I'm gettign a crash/GR when using GetLocaleStr(),, under GCC everything works ok.
Any hints/ideas?
TiA
GetLocaleStr(fgui->mv->locale,MON_1)
[find_wb.c:598 ] ADVANCED_SEARCH=1 [find_wb.c:606 ] readToolTypes() - END [find_wb.c:56 ] Started from Workbench [find_wb.c:59 ] fgui->mv->locale=0x0000600d 54.56 (26.1.2023) Sam460 release Machine model: 7 (Sam460ex) Dump of context at 0xff8587c0 Trap type: DSI exception Machine State (raw): 0x2f030 Machine State (verbose): [ExtInt on] [User] [FPU on] [IAT on] [DAT on] Temporary stack trace: #0: 0x7fff6784 #1: 0x7f64f160 #2: 0x7f646f04 #3: 0x7f646778 #4: 0x7f6463f0 #5: in module Kickstart/kernel+0x54d48 (0x1854d48) #6: in module Kickstart/kernel+0x54dc0 (0x1854dc0) #7: 0x0 Crashed process: Find_debug (0x58431650) 0: 7f64f160 536c3dc0 00000000 6ff195b0 0000600d 0000003b 00000000 0222aefc 8: 00008000 7fffb75c 7fff6744 58430000 24022484 58439a2c 54e9e390 00000000 16: 00000004 54e9e390 00000000 00000000 0000000a 00000000 54625382 00008000 24: 00000000 0195557c 58431650 6ffa1170 02119c2c 0000600d 6ff195b0 0000003b CR: 44022482 XER: 00000002 CTR: 7fffb75c LR: 7f64f160 ESR: 00000000 DEAR: 000060c9 mcsrr0: 0x0 csrr0: 0x0 Disassembly of crash site: 7fff6774: 7cbf2b78 mr r31,r5 7fff6778: 9361002c stw r27,44(r1) 7fff677c: 7d2903a6 mtctr r9 7fff6780: 93810030 stw r28,48(r1) >7fff6784: 808400bc lwz r4,188(r4) 7fff6788: 4e800421 bctrl 7fff678c: 2c030000 cmpwi r3,0 7fff6790: 41c200a4 beq- 0x7FFF6834 7fff6794: 393fffcc subi r9,r31,52 7fff6798: 2b890012 cmplwi cr7,r9,18 Fault caused by load operation Kernel command line: debuglevel=4 SERIAL MUNGE Registers pointing to code: r0 : module Find_debug at 0x7F64F160 (section 0 @ 0x913C) r7 : native kernel module Kickstart/kernel+0x00a2aefc r9 : module LIBS:locale.library at 0x7FFFB75C (section 0 @ 0x8738) r10: module LIBS:locale.library at 0x7FFF6744 (section 0 @ 0x3720) r25: native kernel module Kickstart/dos.library.kmod+0x0002b05c r28: native kernel module Kickstart/kernel+0x00919c2c ip : module LIBS:locale.library at 0x7FFF6784 (section 0 @ 0x3760) lr : module Find_debug at 0x7F64F160 (section 0 @ 0x913C) ctr: module LIBS:locale.library at 0x7FFFB75C (section 0 @ 0x8738) Stack trace: (0x536c3dc0) module LIBS:locale.library at 0x7FFF6784 (section 0 @ 0x3760) (0x536c3e00) module Find_debug at 0x7F64F160 (section 0 @ 0x913C) (0x536c3e60) module Find_debug at 0x7F646F04 (section 0 @ 0xEE0) (0x536c3ee0) module Find_debug at 0x7F646778 (section 0 @ 0x754) (0x536c3f00) Find_debug:_start()+0x3f0 (section 1 @ 0x3EC) (0x536c3fc0) native kernel module Kickstart/kernel+0x00054d48 (0x536c3fd0) native kernel module Kickstart/kernel+0x00054dc0 Disassembly of crash site: 7fff6774: 7cbf2b78 mr r31,r5 7fff6778: 9361002c stw r27,44(r1) 7fff677c: 7d2903a6 mtctr r9 7fff6780: 93810030 stw r28,48(r1) >7fff6784: 808400bc lwz r4,188(r4) 7fff6788: 4e800421 bctrl 7fff678c: 2c030000 cmpwi r3,0 7fff6790: 41c200a4 beq- 0x7FFF6834 7fff6794: 393fffcc subi r9,r31,52 7fff6798: 2b890012 cmplwi cr7,r9,18 Stack pointer (0x536c3dc0) is inside bounds Redzone is OK (4) ...
Noticed one thin with VBCC:
With VBCC mv->locale=0x600da9a0 != fgui->mv->locale=0x0000600d (then crashes)
while with GCC mv->locale=0x600da9a0 == fgui->mv->locale=0x600da9a0
struct FindGUI {
Object *Objects[GID_LAST]; // gadgets/objects
...
struct List *fgui_MM_list;
struct MainVars *mv; // part of Find.c/Find.h by Constantinos Nicolakakis
...
};
struct FindGUI *fgui = AllocVecTags(sizeof(struct FindGUI), AVT_ClearWithValue,NULL, TAG_DONE);
struct MainVars *mv=NULL;
...
fgui->mv = mv; // "points" to struct MainVars
...
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
Looks like an alignment issue. Apparently the code which writes ->locale was aligned to 32 bits while the code which reads it expects alginment to 16 bits.
You should surround the definition of struct MainVars with the right alignment instructions. I don't remember it now, but I think it is #pragma pack(number-of-bytes). You can look into libraries/asl.h for an example.
@thomas
THXaLOT solved, I wasn't "setting" such parameters in one of the headers (the one that declares MainVars)
added
#ifdef __GNUC__
#ifdef __PPC__
#pragma pack(2)
#endif
#elif defined(__VBCC__)
#pragma amiga-align
#endif
and now VBCC build works ok too.
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P