Page 1 of 2
Last Dos library make FastLHA crashed during GetMsg [SOLVED]
Posted: Sun Mar 03, 2013 12:03 am
by zzd10h
Hi,
I have a problem with my tools FastLHA, FastZIP... since today and the last update of Dos.library.
Not everytime but when I launched 4 or 5 times FastLHA, for example, it crashs when using GetMsg (I think).
It worked before the update. When I restore the previous dos.library, it works again.
Addr2line give me the error always here :
DTSoundmsg = (struct DTSoundMessage *)GetMsg(DTMsgPort) ;
message_recu = DTSoundmsg->soundMessage; <= addr2line spots this line.
Crash log for task "FastLHA"
Generated by GrimReaper 53.2
Crash occured in module kernel at address 0x0201A420
Type of crash: DSI (Data Storage Interrupt) exception
Stack trace:
native kernel module kernel+0x0001a420
module FastLHA at 0x7F211520 (section 5 @ 0x11508)
module FastLHA at 0x7F213E84 (section 5 @ 0x13E6C)
native kernel module newlib.library.kmod+0x0000208c
native kernel module newlib.library.kmod+0x00002d34
native kernel module newlib.library.kmod+0x00002eb0
FastLHA:_start()+0x170 (section 1 @ 0x170)
native kernel module dos.library.kmod+0x00022d9c
native kernel module kernel+0x00043054
native kernel module kernel+0x000430d4
When I revert back to the previous dos.library, with cold restart, it works well.
My GetMsg function is waiting for messages of an external program (to notice end of file compression)
The complete CrashLog is here :
http://zzd10h.amiga-ng.org/FastLHA/Crashlog_FastLHA.lha
I know that my program is bad coded but does the GetMsg has changed with this update ?
Thank for your help.
Re: Last Dos library make FastLHA crashed during GetMsg
Posted: Sun Mar 03, 2013 4:29 am
by tonyw
GetMsg() is part of Exec, not DOS. It is unlikely that the latest version of DOS is *causing* your crash - it is more likely that where your program is situated in memory now is making it behave slightly differently than with the older system components.
Since the pointer to the "message" (DTSoundmsg) seems to be rubbish, I would suggest that the address of the MsgPort has been corrupted - or the MsgPort itself has been corrupted, leading to garbage messages being retrieved from it.
So I would suggest looking very carefully at your DTMsgPort.
Where is it? I hope it's not on the stack somewhere, it's likely to be over-written by anything.
Is there a text buffer nearby, that could be overflowing and writing over it?
Have a good look. If you can't see any problem, try putting a longword on either side of the MsgPort, filling them with some magic number and then checking the contents before you take the message as gospel.
At the other end, are you sure that the thing that is sending the message is sending something sensible? At least get it to print out what it is sending, and compare that with what you receive.
Re: Last Dos library make FastLHA crashed during GetMsg
Posted: Sun Mar 03, 2013 8:36 am
by thomasrapp
zzd10h wrote:DTSoundmsg = (struct DTSoundMessage *)GetMsg(DTMsgPort) ;
message_recu = DTSoundmsg->soundMessage; <= addr2line spots this line.
GetMsg may return NULL. You don't check this. If it is NULL you crash.
Re: Last Dos library make FastLHA crashed during GetMsg
Posted: Sun Mar 03, 2013 11:07 am
by zzd10h
Thank you for advices, Thomas and Tony.
I just add a printf
DTSoundmsg = (struct DTSoundMessage *)GetMsg(DTMsgPort) ;
printf("DTSoundmsg %d\n",DTSoundmsg);
When it works, DTSoundmsg = 45285376 but when it failed it's negative, -1485648334.
I don't see a text buffer nearby and my structure is
struct DTSoundMessage
{
struct Message sound_Msg;
int soundMessage;
};
struct MsgPort *DTMsgPort;
Tonyw, what do you mean by
"try putting a longword on either side of the MsgPort, filling them with some magic number" ? and how to check if I'm on the stack ?
Thank for your very kind help
Guillaume
Re: Last Dos library make FastLHA crashed during GetMsg
Posted: Sun Mar 03, 2013 12:59 pm
by thomasrapp
Use %lx instead of %d.
Print the address before you PutMsg() it, too.
struct MsgPort *DTMsgPort;
How do you fill this pointer with a value? Do you ever CreateMsgPort() or AllocSysObject(ASOT_PORT)?
Who allocates the message and how? When is it freed?
Re: Last Dos library make FastLHA crashed during GetMsg
Posted: Sun Mar 03, 2013 1:23 pm
by zzd10h
When I use %lx I obtain
DTSoundmsg 2b30000 (when it works)
DTSoundmsg ea6c9344 (when it failed)
The PutMsg is on external program with
Forbid();
struct MsgPort *port = FindPort(nom_msgport);
if (port != NULL)
{
PutMsg(port,(struct Message *)FastLHAmsg);
Permit();
}
else
{
Permit();
}
In the main program (FastLHA) I open the port with
DTMsgPort = AllocSysObjectTags(ASOT_PORT,ASOPORT_Name,nom_msgport,TAG_END)
and I closed it at the end of compression (just before to end the program)
if (DTMsgPort)
FreeSysObject(ASOT_PORT, DTMsgPort);
Re: Last Dos library make FastLHA crashed during GetMsg
Posted: Sun Mar 03, 2013 6:19 pm
by thomasrapp
Who allocates the message? Who frees the message an when?
Re: Last Dos library make FastLHA crashed during GetMsg
Posted: Sun Mar 03, 2013 7:25 pm
by zzd10h
I didn't allocate/free message with AllocSysObjects/FreeSysObject before to read your question.
Now, I have corrected it but no changes... it works with old library but not with the new one after few tests.
In the program who send message, I add
struct FastLHAMessage *FastLHAmsg = AllocSysObjectTags(ASOT_MESSAGE, ASOMSG_Size,sizeof(struct FastLHAMessage),TAG_END);
before to FindPort and PutMsg
In the program who receive the message, after to have save it, I
DTSoundmsg = GetMsg(DTMsgPort) ;
printf("DTSoundmsg %lx %lx\n",DTSoundmsg,DTMsgPort);
message_recu = DTSoundmsg->soundMessage;
FreeSysObject(ASOT_MESSAGE,DTSoundmsg);
Re: Last Dos library make FastLHA crashed during GetMsg
Posted: Sun Mar 03, 2013 10:01 pm
by zzd10h
Hi again,
I have the same problem (DSI during GetMsg) with a littler program that I have released on OS4Depot (with sources).
This program works well when I rollback to the previous dos.library (and cold reboot).
It's based on the same message principle that FastLHA (the crash is coherent

)
http://zzd10h.amiga-ng.org/Divers/GetMs ... und_KO.jpg
I put last sources and executables (with gstabs) on this link :
http://zzd10h.amiga-ng.org/Divers/GetMs ... Signal.lha
Please, is somebody could test it by opening 2 shells, with last dos.library (53.126).
1) In the first one, type :
DataType_Sound Test.wav 99 1 1 01 debug
to play the sound test.wav at volume 1 with increment of 1 (for future increase of volume) on port 01 with debug.
2) in the second shell, type many many times to send message of volume UP to the first program :
DataType_Sound_Break up 01 debug
For me with the new dos.library it fails at the second attempt to increase the volume.
Note : I don't modify it to add allocation/deallocation of messages, it worked like this before...
Thank by advance
Guillaume
Re: Last Dos library make FastLHA crashed during GetMsg
Posted: Sun Mar 03, 2013 10:21 pm
by thomasrapp
struct DTSoundMessage *DTSoundmsg ;
if (STOP)
DTSoundmsg->soundMessage = 999;
You never allocate memory for your message. You just use an uninitialized pointer and poke into the memory the pointer points to. Actually this should already crash. It's just a wonder that on the first attempt you hit valid memory.