Asl.library FileRequester crashes when selected assign/volume doesn't exist

12 posts / 0 new
Last post
blmara
blmara's picture
Offline
Last seen: 3 years 10 months ago
Joined: 2013-10-31 00:20
Asl.library FileRequester crashes when selected assign/volume doesn't exist

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!)

  1. #include <proto/asl.h>
  2. #include <proto/dos.h>
  3. #include <proto/exec.h>
  4. #include <libraries/asl.h>
  5. #include "string.h"
  6.  
  7. /*
  8. ** compiled with:
  9. ** vc aslproblem.c -o ram:aslproblem +newlib
  10. */
  11.  
  12. struct AslIFace *IAsl;
  13. struct FileRequester *FileReq;
  14. struct Library *base;
  15. STRPTR Testname = "Test:testing";
  16.  
  17. int main(int ac,char *av[])
  18. {
  19. STRPTR docname,dirname;
  20. int dirlen;
  21.  
  22. if (base = IExec->OpenLibrary("asl.library",53L))
  23. {
  24. if (IAsl = (struct AslIFace *)IExec->GetInterface(base,"main",1,NULL))
  25. {
  26. FileReq = IAsl->AllocAslRequestTags(ASL_FileRequest,
  27. ASLFR_StayOnTop,TRUE,
  28. ASLFR_RejectIcons,TRUE,
  29. ASLFR_PrivateIDCMP,TRUE,
  30. ASLFR_SleepWindow,TRUE,
  31. ASLFR_DoPatterns,TRUE,
  32. TAG_DONE);
  33. dirlen = IDOS->FilePart(Testname) - Testname;
  34. if (dirname = IExec->AllocVecTags(dirlen+1,TAG_DONE))
  35. {
  36. strncpy(dirname,Testname,dirlen);
  37. *(dirname+dirlen) = '\0'; /* note: strncpy doesn't put NUL if strlen(Testname) > dirlen! */
  38. }
  39. if (FileReq)
  40. {
  41. IAsl->AslRequestTags(FileReq,
  42. ASLFR_TitleText,"Testing!",
  43. ASLFR_InitialDrawer,dirname,
  44. ASLFR_InitialFile,IDOS->FilePart(Testname),
  45. ASLFR_InitialPattern,"(#?.xml|#?.mxl)",
  46. ASLFR_DoSaveMode,TRUE,
  47. TAG_DONE);
  48. IAsl->FreeAslRequest(FileReq);
  49. }
  50. if (dirname)
  51. IExec->FreeVec(dirname);
  52. IExec->DropInterface((struct Interface *)IAsl);
  53. }
  54. IExec->CloseLibrary(base);
  55. }
  56. return(0);
  57. }

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.

  1. [_impl_AddTask] Adding Task 0x5a1a0a20, intuition.task (0x2834f9c)
  2. [_impl_AddTask] Task = 0x5a1a0a20, ETask = 0xdfb47e50, Context = 0xdfb9e3e0
  3. [_impl_AddTask] Stack bottom = 0x52d20000, Stack top = 0x52d28000, Stack pointer = 0x52d27fd0
  4. [_impl_AddTask] Task added to ready list
  5. [HAL_DfltTrapHandler] *** Warning: Fatal exception in task 0x55d41620 (ScoreGen, etask = 0xdfb47c10) at ip 0x21ee824
  6. [HAL_Alert] ALERT! 0x80000003
  7. Dump of context at 0xdfff4ba0
  8. Trap type: DSI exception
  9. Machine State (raw): 0x100000000200b030
  10. Machine State (verbose): [Hyper] [ExtInt on] [Super] [FPU on] [IAT on] [DAT on]
  11. Instruction pointer: in module intuition.library.kmod+0x1b7e4 (0x21ee824)
  12. Crashed process: ScoreGen (0x55d41620)
  13. DSI verbose error description: Access not found in hash or BAT (page fault)
  14. Access was a load operation
  15. 0: 021ee92c 57cc1370 00000000 6fe39088 00000000 cafead83 57cc1408 cafead83
  16. 8: 02029bf4 02b40000 00000000 6ff364d0 44422088 7fd5d440 cafeabad 624353d4
  17. 16: 5960d48c 57cc1a44 00000000 00000000 61510000 6fc445d0 616eba10 615150a0
  18. 24: 0000000d 5960d48c 57cc1840 57cc1408 6ff364d0 cafead83 6fe39088 61bfd020
  19. CR: 84422088 XER: 20000000 CTR: 021ee76c LR: 021ee818
  20. DSISR: 40000000 DAR: cafead83
  21.  
  22. FP0 : fff8000082004000 ffcfcfcfffcfcfcf ffcfcfcfffcfcfcf ffcfcfcfffcfcfcf
  23. FP4 : ffcfcfcfffcfcfcf ffcfcfcfffcfcfcf ffcfcfcfffcfcfcf ffcfcfcfffcfcfcf
  24. FP8 : ffcfcfcfffcfcfcf ffcfcfcfffcfcfcf 0000000000000000 4330000080000568
  25. FP12: 4330000080000368 4088480000000000 0000000000000000 0000000000000000
  26. FP16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  27. FP20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  28. FP24: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  29. FP28: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  30. FPSCR: 82004000
  31. HID0: 0x8000000000000000 HID1: 0x000000005ce993b1
  32. HID4: 0x4400240000080180 HID5: 0x0000006600000080
  33.  
  34. V0 : 00000000000000000000000000000000 08090a0b0c0d0e0f1011121314151617
  35. V2 : ffcfcfcfffcfcfcfffcfcfcfffcfcfcf ff01cf31ff01cf31ff01cf31ff01cf31
  36. V4 : ff01cf31ff01cf31ff01cf31ff01cf31 cf31cf31cf31cf31cf31cf31cf31cf31
  37. V6 : ff01cf31ff01cf31ff01cf31ff01cf31 fe01ce31fe01ce31fe01ce31fe01ce31
  38. V8 : fe01ce31fe01ce31fe01ce31fe01ce31 ffcfcfcfffcfcfcfffcfcfcfffcfcfcf
  39. V10: ffcfcfcfffcfcfcfffcfcfcfffcfcfcf cf31cf31cf31cf31cf31cf31cf31cf31
  40. V12: ff01cf31ff01cf31ff01cf31ff01cf31 ffcfcfcfffcfcfcfffcfcfcfffcfcfcf
  41. V14: 001002120414061608180a1a0c1c0e1e 01000100010001000100010001000100
  42. V16: ff000000ff000000ff000000ff000000 ffcfcfcfffcfcfcfffcfcfcfffcfcfcf
  43. V18: fe01ce31fe01ce31fe01ce31fe01ce31 ffcfcfcfffcfcfcfffcfcfcfffcfcfcf
  44. V20: 00000000000000000000000000000000 00000000000000000000000000000000
  45. V22: 00000000000000000000000000000000 00000000000000000000000000000000
  46. V24: 00000000000000000000000000000000 00000000000000000000000000000000
  47. V26: 00000000000000000000000000000000 00000000000000000000000000000000
  48. V28: 00000000000000000000000000000000 00000000000000000000000000000000
  49. V30: 00000000000000000000000000000000 00000000000000000000000000000000
  50. VSCR: 00000000 VRSAVE: 00000000
  51.  
  52. Disassembly of crash site:
  53. 021ee814: 4e800421 bctrl
  54. 021ee818: 2f9d0000 cmpwi cr7,r29,0
  55. 021ee81c: 7c7e1b78 mr r30,r3
  56. 021ee820: 419e0058 beq- cr7,0x21EE878
  57. >021ee824: a01d0000 lhz r0,0(r29)
  58. 021ee828: 2b800002 cmplwi cr7,r0,2
  59. 021ee82c: 409d004c ble- cr7,0x21EE878
  60. 021ee830: 807d001e lwz r3,30(r29)
  61. 021ee834: 2f830000 cmpwi cr7,r3,0
  62. 021ee838: 419e00a4 beq- cr7,0x21EE8DC
  63.  
  64. Kernel command line: DEBUGLEVEL=5 SERIAL MUNGE
  65.  
  66. Registers pointing to code:
  67. r0 : native kernel module intuition.library.kmod+0x0001b8ec
  68. r8 : native kernel module kernel.debug+0x00029bf4
  69. r9 : native kernel module graphics.library.kmod+0x0082a120
  70. r13: module LIBS:xadmaster.library at 0x7FD5D440 (section 5 @ 0x741C)
  71. r20: module IPrefs at 0x61510000 (section 4 @ 0xFDC)
  72. r23: module IPrefs at 0x615150A0 (section 4 @ 0x607C)
  73. ip : native kernel module intuition.library.kmod+0x0001b7e4
  74. lr : native kernel module intuition.library.kmod+0x0001b7d8
  75. ctr: native kernel module intuition.library.kmod+0x0001b72c
  76.  
  77. Stack trace:
  78. (0x57cc1370) native kernel module intuition.library.kmod+0x0001b7e4
  79. (0x57cc1390) native kernel module intuition.library.kmod+0x0001b7d8
  80. (0x57cc1400) module CLASSES:requester.class at 0x7FAF450C (section 5 @ 0x44E8)
  81. (0x57cc1740) native kernel module intuition.library.kmod+0x00020da8
  82. (0x57cc17a0) native kernel module intuition.library.kmod+0x00020f4c
  83. (0x57cc1820) native kernel module intuition.library.kmod+0x0000a044
  84. (0x57cc1830) module IPrefs at 0x7FF513F4 (section 5 @ 0xF3D0)
  85. (0x57cc1950) native kernel module dos.library.kmod+0x00032b20
  86. (0x57cc19d0) native kernel module dos.library.kmod+0x00025e3c
  87. (0x57cc1d10) native kernel module dos.library.kmod+0x0000dcdc
  88. (0x57cc1d30) native kernel module dos.library.kmod+0x0000e214
  89. (0x57cc1f90) native kernel module dos.library.kmod+0x0001636c
  90. (0x57cc22a0) native kernel module dos.library.kmod+0x00015f50
  91. (0x57cc22b0) native kernel module dos.library.kmod+0x0001afbc
  92. (0x57cc2310) module LIBS:asl.library at 0x7FAB2080 (section 5 @ 0xD05C)
  93. (0x57cc28b0) module LIBS:asl.library at 0x7FAB6D54 (section 5 @ 0x11D30)
  94. (0x57cc2920) module LIBS:asl.library at 0x7FAA6028 (section 5 @ 0x1004)
  95. (0x57cc29a0) module LIBS:asl.library at 0x7FAA5AF4 (section 5 @ 0xAD0)
  96. (0x57cc2a10) SaveAsDoc()+0x1b4 (section 7 @ 0x76400)
  97. (0x57cc2a90) HandleDocInput()+0x1110 (section 7 @ 0x6320C)
  98. (0x57cc2ba0) Doc_Dispatch()+0x4d0 (section 7 @ 0x5EB0C)
  99. (0x57cc2c80) MainGUI()+0x2bc (section 7 @ 0x4D608)
  100. (0x57cc2ce0) main()+0x5c (section 7 @ 0x4E9D8)
  101. (0x57cc2d00) native kernel module newlib.library.kmod+0x000020a4
  102. (0x57cc2d70) native kernel module newlib.library.kmod+0x00002d0c
  103. (0x57cc2f10) native kernel module newlib.library.kmod+0x00002ee8
  104. (0x57cc2f50) _start()+0x16c (section 7 @ 0x168)
  105. (0x57cc2f90) native kernel module dos.library.kmod+0x00024c18
  106. (0x57cc2fc0) native kernel module kernel.debug+0x00069b3c
  107. (0x57cc2fd0) native kernel module kernel.debug+0x00069bbc
  108.  
  109. Disassembly of crash site:
  110. 021ee814: 4e800421 bctrl
  111. 021ee818: 2f9d0000 cmpwi cr7,r29,0
  112. 021ee81c: 7c7e1b78 mr r30,r3
  113. 021ee820: 419e0058 beq- cr7,0x21EE878
  114. >021ee824: a01d0000 lhz r0,0(r29)
  115. 021ee828: 2b800002 cmplwi cr7,r0,2
  116. 021ee82c: 409d004c ble- cr7,0x21EE878
  117. 021ee830: 807d001e lwz r3,30(r29)
  118. 021ee834: 2f830000 cmpwi cr7,r3,0
  119. 021ee838: 419e00a4 beq- cr7,0x21EE8DC
  120. Stack pointer (0x57cc1370) is inside bounds
  121. Redzone is OK (4)
  122.  
  123. 68k register dump
  124. DATA: 00000001 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  125. ----> 00000001 - "DEVS:lpr.device" Hunk 0000 Offset 00000000 (SegList: 0x1658912d)
  126. ADDR: 6ffb8700 9126bc00 00000000 00000000 00000000 00000000 00000000 57cc1150
  127. Page information:
  128. Page not found
  129.  
  130.  
  131. [_impl_AddTask] Adding Task 0x596241b0, Background CLI (0x5a6302a0)
  132. [_impl_AddTask] Task = 0x596241b0, ETask = 0xdfb47e50, Context = 0xdfb9e3e0
  133. [_impl_AddTask] Stack bottom = 0x5e3e9038, Stack top = 0x5e3ed024, Stack pointer = 0x5e3ecff0
  134. [_impl_AddTask] Task added to ready list

Marko

xenic
xenic's picture
Offline
Last seen: 1 year 11 months ago
Joined: 2011-05-07 04:52
Re: Asl.library FileRequester crashes when selected assign...

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

blmara
blmara's picture
Offline
Last seen: 3 years 10 months ago
Joined: 2013-10-31 00:20
Re: Asl.library FileRequester crashes when selected assign...

@xenic

Thanks, I actually found this link also while wondering why my drawer names looked so odd ;->

Marko

Marko

jabirulo
jabirulo's picture
Offline
Last seen: 6 hours 32 min ago
Joined: 2013-05-30 00:53
Re: Asl.library FileRequester crashes when selected assign...

and if you put hardcoded drawer and filename does it crash too?

  1. ASLFR_InitialDrawer, "Test:",
  2. ASLFR_InitialFile, "testing",

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

salass00
salass00's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-02-03 11:27
Re: Asl.library FileRequester crashes when selected assign...

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.

hypex
hypex's picture
Offline
Last seen: 1 month 2 weeks ago
Joined: 2011-09-09 16:20
Re: Asl.library FileRequester crashes when selected assign...

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.

blmara
blmara's picture
Offline
Last seen: 3 years 10 months ago
Joined: 2013-10-31 00:20
Re: Asl.library FileRequester crashes when selected assign...

@jabirulo

Yes, it crashes then too.

Marko

Marko

blmara
blmara's picture
Offline
Last seen: 3 years 10 months ago
Joined: 2013-10-31 00:20
Re: Asl.library FileRequester crashes when selected assign...

@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.

  1. struct Interface *InitIface(STRPTR libname,ULONG libversion,STRPTR ifacename,ULONG ifaceversion)
  2. {
  3. struct Interface *iface = NULL;
  4. struct Library *base;
  5.  
  6. /*
  7. ** Opens a global interface of a library. Note that the library base
  8. ** is not saved to global library base variable anymore (see SDK 53.24
  9. ** release FAQ.
  10. **
  11. ** IExec and IDOS are opened by compiler code automatically.
  12. ** application.library's lib base is obtained from IApplication
  13. ** if it has been already GetInterface()'d to avoid double opening.
  14. **
  15. ** Note that if a different thread/task uses the same interface, it
  16. ** has to do a iface->Obtain()---iface->Release() pair see autodoc
  17. ** of IExec->GetInterface().
  18. */
  19. if (ifacename == prefsifacename)
  20. base = IApplication->Data.LibBase;
  21. else
  22. base = IExec->OpenLibrary(libname,libversion);
  23.  
  24. if (base)
  25. {
  26. if (iface = IExec->GetInterface(base,ifacename,ifaceversion,NULL))
  27. {
  28. /* ok */
  29. }
  30. else
  31. if (ifacename != prefsifacename) /* don't close application.library if prefsobjects interface failed */
  32. IExec->CloseLibrary(base);
  33. }
  34.  
  35. if (iface == NULL)
  36. ErrorCode = MSG_ERROR_LIBRARYWONTOPEN;
  37. return(iface);
  38. }
  39.  
  40. void CloseIFace(struct Interface *iface)
  41. {
  42. struct Library *base;
  43.  
  44. /*
  45. ** Drops interface and closes a library
  46. ** Doesn't close library if application.library's IPrefsObject cause still in use
  47. */
  48. if (iface)
  49. {
  50. base = iface->Data.LibBase;
  51. IExec->DropInterface(iface);
  52. if (iface != (struct Interface *)IPrefsObjects)
  53. IExec->CloseLibrary(base);
  54. }
  55. }

Marko

hypex
hypex's picture
Offline
Last seen: 1 month 2 weeks ago
Joined: 2011-09-09 16:20
Re: Asl.library FileRequester crashes when selected assign...

@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. :-)

hypex
hypex's picture
Offline
Last seen: 1 month 2 weeks ago
Joined: 2011-09-09 16:20
Re: Asl.library FileRequester crashes when selected assign...

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.

blmara
blmara's picture
Offline
Last seen: 3 years 10 months ago
Joined: 2013-10-31 00:20
Re: Asl.library FileRequester crashes when selected assign...

@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

thomas
thomas's picture
Offline
Last seen: 11 hours 51 min ago
Joined: 2011-05-16 14:23
Re: Asl.library FileRequester crashes when selected assign...

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.

Log in or register to post comments