Hi,
in my program I use Asl file requester both through IASL->AslRequestTags and through getfile.gadget functions. I noticed that for some reason, both ways lead to crash if I give non-existing volume name to either ASLFR_InitialDrawer or entering such in the file requester Drawer field. If entering only non-existing drawer name (without volume name like Test:) causes fr to ask whether one should create a new drawer, as it should.
I extracted my Asl code to the file above. This code, however, doesn't crash but ask for reassignment as it should. I'm quite puzzled what's causing this. Would the GR log help to understand the problem. BTW, I don't have any global library bases stored in my program but using only the interfaces, would this affect asl.library?
I'm using AmigaOne X1000, OS41FE, the kernel.debug is effective.
Extracted code (which, runned separately, doesn't crash!)
#include <proto/asl.h> #include <proto/dos.h> #include <proto/exec.h> #include <libraries/asl.h> #include "string.h" /* ** compiled with: ** vc aslproblem.c -o ram:aslproblem +newlib */ struct AslIFace *IAsl; struct FileRequester *FileReq; struct Library *base; STRPTR Testname = "Test:testing"; int main(int ac,char *av[]) { STRPTR docname,dirname; int dirlen; if (base = IExec->OpenLibrary("asl.library",53L)) { if (IAsl = (struct AslIFace *)IExec->GetInterface(base,"main",1,NULL)) { FileReq = IAsl->AllocAslRequestTags(ASL_FileRequest, ASLFR_StayOnTop,TRUE, ASLFR_RejectIcons,TRUE, ASLFR_PrivateIDCMP,TRUE, ASLFR_SleepWindow,TRUE, ASLFR_DoPatterns,TRUE, TAG_DONE); dirlen = IDOS->FilePart(Testname) - Testname; if (dirname = IExec->AllocVecTags(dirlen+1,TAG_DONE)) { strncpy(dirname,Testname,dirlen); *(dirname+dirlen) = '\0'; /* note: strncpy doesn't put NUL if strlen(Testname) > dirlen! */ } if (FileReq) { IAsl->AslRequestTags(FileReq, ASLFR_TitleText,"Testing!", ASLFR_InitialDrawer,dirname, ASLFR_InitialFile,IDOS->FilePart(Testname), ASLFR_InitialPattern,"(#?.xml|#?.mxl)", ASLFR_DoSaveMode,TRUE, TAG_DONE); IAsl->FreeAslRequest(FileReq); } if (dirname) IExec->FreeVec(dirname); IExec->DropInterface((struct Interface *)IAsl); } IExec->CloseLibrary(base); } return(0); }
and GR log through Sashimi (here, the SaveAsDoc() is the routine calling AslRequestTags. Note that requester starts properly. Crash comes when one enters the non-existing Test: volume name into Drawer field of requester.
[_impl_AddTask] Adding Task 0x5a1a0a20, intuition.task (0x2834f9c) [_impl_AddTask] Task = 0x5a1a0a20, ETask = 0xdfb47e50, Context = 0xdfb9e3e0 [_impl_AddTask] Stack bottom = 0x52d20000, Stack top = 0x52d28000, Stack pointer = 0x52d27fd0 [_impl_AddTask] Task added to ready list [HAL_DfltTrapHandler] *** Warning: Fatal exception in task 0x55d41620 (ScoreGen, etask = 0xdfb47c10) at ip 0x21ee824 [HAL_Alert] ALERT! 0x80000003 Dump of context at 0xdfff4ba0 Trap type: DSI exception Machine State (raw): 0x100000000200b030 Machine State (verbose): [Hyper] [ExtInt on] [Super] [FPU on] [IAT on] [DAT on] Instruction pointer: in module intuition.library.kmod+0x1b7e4 (0x21ee824) Crashed process: ScoreGen (0x55d41620) DSI verbose error description: Access not found in hash or BAT (page fault) Access was a load operation 0: 021ee92c 57cc1370 00000000 6fe39088 00000000 cafead83 57cc1408 cafead83 8: 02029bf4 02b40000 00000000 6ff364d0 44422088 7fd5d440 cafeabad 624353d4 16: 5960d48c 57cc1a44 00000000 00000000 61510000 6fc445d0 616eba10 615150a0 24: 0000000d 5960d48c 57cc1840 57cc1408 6ff364d0 cafead83 6fe39088 61bfd020 CR: 84422088 XER: 20000000 CTR: 021ee76c LR: 021ee818 DSISR: 40000000 DAR: cafead83 FP0 : fff8000082004000 ffcfcfcfffcfcfcf ffcfcfcfffcfcfcf ffcfcfcfffcfcfcf FP4 : ffcfcfcfffcfcfcf ffcfcfcfffcfcfcf ffcfcfcfffcfcfcf ffcfcfcfffcfcfcf FP8 : ffcfcfcfffcfcfcf ffcfcfcfffcfcfcf 0000000000000000 4330000080000568 FP12: 4330000080000368 4088480000000000 0000000000000000 0000000000000000 FP16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 FP20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 FP24: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 FP28: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 FPSCR: 82004000 HID0: 0x8000000000000000 HID1: 0x000000005ce993b1 HID4: 0x4400240000080180 HID5: 0x0000006600000080 V0 : 00000000000000000000000000000000 08090a0b0c0d0e0f1011121314151617 V2 : ffcfcfcfffcfcfcfffcfcfcfffcfcfcf ff01cf31ff01cf31ff01cf31ff01cf31 V4 : ff01cf31ff01cf31ff01cf31ff01cf31 cf31cf31cf31cf31cf31cf31cf31cf31 V6 : ff01cf31ff01cf31ff01cf31ff01cf31 fe01ce31fe01ce31fe01ce31fe01ce31 V8 : fe01ce31fe01ce31fe01ce31fe01ce31 ffcfcfcfffcfcfcfffcfcfcfffcfcfcf V10: ffcfcfcfffcfcfcfffcfcfcfffcfcfcf cf31cf31cf31cf31cf31cf31cf31cf31 V12: ff01cf31ff01cf31ff01cf31ff01cf31 ffcfcfcfffcfcfcfffcfcfcfffcfcfcf V14: 001002120414061608180a1a0c1c0e1e 01000100010001000100010001000100 V16: ff000000ff000000ff000000ff000000 ffcfcfcfffcfcfcfffcfcfcfffcfcfcf V18: fe01ce31fe01ce31fe01ce31fe01ce31 ffcfcfcfffcfcfcfffcfcfcfffcfcfcf V20: 00000000000000000000000000000000 00000000000000000000000000000000 V22: 00000000000000000000000000000000 00000000000000000000000000000000 V24: 00000000000000000000000000000000 00000000000000000000000000000000 V26: 00000000000000000000000000000000 00000000000000000000000000000000 V28: 00000000000000000000000000000000 00000000000000000000000000000000 V30: 00000000000000000000000000000000 00000000000000000000000000000000 VSCR: 00000000 VRSAVE: 00000000 Disassembly of crash site: 021ee814: 4e800421 bctrl 021ee818: 2f9d0000 cmpwi cr7,r29,0 021ee81c: 7c7e1b78 mr r30,r3 021ee820: 419e0058 beq- cr7,0x21EE878 >021ee824: a01d0000 lhz r0,0(r29) 021ee828: 2b800002 cmplwi cr7,r0,2 021ee82c: 409d004c ble- cr7,0x21EE878 021ee830: 807d001e lwz r3,30(r29) 021ee834: 2f830000 cmpwi cr7,r3,0 021ee838: 419e00a4 beq- cr7,0x21EE8DC Kernel command line: DEBUGLEVEL=5 SERIAL MUNGE Registers pointing to code: r0 : native kernel module intuition.library.kmod+0x0001b8ec r8 : native kernel module kernel.debug+0x00029bf4 r9 : native kernel module graphics.library.kmod+0x0082a120 r13: module LIBS:xadmaster.library at 0x7FD5D440 (section 5 @ 0x741C) r20: module IPrefs at 0x61510000 (section 4 @ 0xFDC) r23: module IPrefs at 0x615150A0 (section 4 @ 0x607C) ip : native kernel module intuition.library.kmod+0x0001b7e4 lr : native kernel module intuition.library.kmod+0x0001b7d8 ctr: native kernel module intuition.library.kmod+0x0001b72c Stack trace: (0x57cc1370) native kernel module intuition.library.kmod+0x0001b7e4 (0x57cc1390) native kernel module intuition.library.kmod+0x0001b7d8 (0x57cc1400) module CLASSES:requester.class at 0x7FAF450C (section 5 @ 0x44E8) (0x57cc1740) native kernel module intuition.library.kmod+0x00020da8 (0x57cc17a0) native kernel module intuition.library.kmod+0x00020f4c (0x57cc1820) native kernel module intuition.library.kmod+0x0000a044 (0x57cc1830) module IPrefs at 0x7FF513F4 (section 5 @ 0xF3D0) (0x57cc1950) native kernel module dos.library.kmod+0x00032b20 (0x57cc19d0) native kernel module dos.library.kmod+0x00025e3c (0x57cc1d10) native kernel module dos.library.kmod+0x0000dcdc (0x57cc1d30) native kernel module dos.library.kmod+0x0000e214 (0x57cc1f90) native kernel module dos.library.kmod+0x0001636c (0x57cc22a0) native kernel module dos.library.kmod+0x00015f50 (0x57cc22b0) native kernel module dos.library.kmod+0x0001afbc (0x57cc2310) module LIBS:asl.library at 0x7FAB2080 (section 5 @ 0xD05C) (0x57cc28b0) module LIBS:asl.library at 0x7FAB6D54 (section 5 @ 0x11D30) (0x57cc2920) module LIBS:asl.library at 0x7FAA6028 (section 5 @ 0x1004) (0x57cc29a0) module LIBS:asl.library at 0x7FAA5AF4 (section 5 @ 0xAD0) (0x57cc2a10) SaveAsDoc()+0x1b4 (section 7 @ 0x76400) (0x57cc2a90) HandleDocInput()+0x1110 (section 7 @ 0x6320C) (0x57cc2ba0) Doc_Dispatch()+0x4d0 (section 7 @ 0x5EB0C) (0x57cc2c80) MainGUI()+0x2bc (section 7 @ 0x4D608) (0x57cc2ce0) main()+0x5c (section 7 @ 0x4E9D8) (0x57cc2d00) native kernel module newlib.library.kmod+0x000020a4 (0x57cc2d70) native kernel module newlib.library.kmod+0x00002d0c (0x57cc2f10) native kernel module newlib.library.kmod+0x00002ee8 (0x57cc2f50) _start()+0x16c (section 7 @ 0x168) (0x57cc2f90) native kernel module dos.library.kmod+0x00024c18 (0x57cc2fc0) native kernel module kernel.debug+0x00069b3c (0x57cc2fd0) native kernel module kernel.debug+0x00069bbc Disassembly of crash site: 021ee814: 4e800421 bctrl 021ee818: 2f9d0000 cmpwi cr7,r29,0 021ee81c: 7c7e1b78 mr r30,r3 021ee820: 419e0058 beq- cr7,0x21EE878 >021ee824: a01d0000 lhz r0,0(r29) 021ee828: 2b800002 cmplwi cr7,r0,2 021ee82c: 409d004c ble- cr7,0x21EE878 021ee830: 807d001e lwz r3,30(r29) 021ee834: 2f830000 cmpwi cr7,r3,0 021ee838: 419e00a4 beq- cr7,0x21EE8DC Stack pointer (0x57cc1370) is inside bounds Redzone is OK (4) 68k register dump DATA: 00000001 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ----> 00000001 - "DEVS:lpr.device" Hunk 0000 Offset 00000000 (SegList: 0x1658912d) ADDR: 6ffb8700 9126bc00 00000000 00000000 00000000 00000000 00000000 57cc1150 Page information: Page not found [_impl_AddTask] Adding Task 0x596241b0, Background CLI (0x5a6302a0) [_impl_AddTask] Task = 0x596241b0, ETask = 0xdfb47e50, Context = 0xdfb9e3e0 [_impl_AddTask] Stack bottom = 0x5e3e9038, Stack top = 0x5e3ed024, Stack pointer = 0x5e3ecff0 [_impl_AddTask] Task added to ready list
Marko
Without the ability to reproduce the crash, I can't help but maybe someone else can. However, I can comment on an unrelated issue in your example code. I don't think you will need line 37and the accompanying comment if you replace strncpy() with strlcpy(). Here is one of many explanations you can find by googling strlcpy:
https://en.wikibooks.org/wiki/C_Programming/C_Reference/nonstandard/strlcpy
X1000 - OS 4.1FE
@xenic
Thanks, I actually found this link also while wondering why my drawer names looked so odd ;->
Marko
Marko
and if you put hardcoded drawer and filename does it crash too?
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
Given that the number of characters to copy is known it would be more efficient to just replace strncpy() with memcpy().
BTW I tried writing a phony volume name in both a file requester (both normal and save type) and in a getfile gadget but I wasn't able to make it crash like this on my AmigaOS 4.1 beta install.
If you want to be consistent in your code you could use malloc() or calloc() if you like it cleared.
You said you don't store global library bases but where do you put them? For your own use you only need the interface pointer. But the library base will need to be opened obviously and closed later.
This begs the question. You extracted code that works by itself. But what do you do with the library base? Is your code single threaded? You open ASL library and interface from one task and call it from that one task? Otherwise you can get into trouble.
@jabirulo
Yes, it crashes then too.
Marko
Marko
@hypex
Single threaded currently. I use these routines at start and end of my program to make opening/closing libraries (and Reaction classes with slightly modified code) more compact and the possible error message output esier. So, the library base needed when closing a library is captured from struct Interface.
Marko
@blmara
Okay I can understand now. I've considered doing something similar myself. I thought shortcuts may be standardised but so far looks like we are still on our own. For example I had this idea to give standard Amiga libraries ID numbers so that a table could be built up with the ones you want. And possibly passing the pointer addresses as well but automating it would be good.
Anyway will do some tests when I'm on OS4 next. If the base and interface pointer are correctly initialised then there should be no problem. But youy never know until you find it. :-)
Three things come to mind.
Your library opening code is different for a start. That may cause an issue.
It's possible dirname could be a rogue string. I've had random corruption when not all characters were cleared and I used "hacks" to poke EOL bytes in. In your bad code try clearing the whole string before copying. In your good code fil lit with "rogue" chars before your copy.
Passing patterns to file requester. I've had trouble with this and it may have only been on OS4 I noticed or when it crashed. It's only mentioned for ASLFR_RejectPattern and ASLFR_AcceptPattern but according to that ParsePatternNoCase() must be used when passing a pattern. And a normal pattern string is not acceptable.
@hypex
Thanks, I tried something:
- put up a normal AslBase
- cleared the dirname buffer with memset()
- removed InitialPattern
These didn't help, crashed if I put Test: to drawer gadget.
Still wondering.
Marko
Marko
Well, it obviously crashes when trying to show the "please inset volume Test in any drive" requester. It runs through IPrefs, requester.class and crashes somewhere in intuition.library.
So the question is, did you do something to the standard environment? Did you change the default public screen? Did you do something to your Process->pr_WindowPtr?
What about ASLFR_Window and ASLFR_Screen? Do you supply these and are they valid window resp. screen pointers?
In your above example you put ASLFR_SleepWindow,TRUE which does not make any sense without a ASLFR_Window.
Did you actually read up all the tags you are using and did you understand what they are good for?
You should make an example which uses *exactly* the code from your crashing program. I.e. keep the SaveAsDoc routine as is, just add a new main() routine as a test driver.