Closed andrewbird closed 5 years ago
Would be cool if you can debug this a bit...
For reference the block driver is at https://github.com/andrewbird/dosemu2/tree/emudsk01-sys, but I expect the same thing to occur with other block drivers.
Yes, I can have a look, do you an idea where to start?
Yes, I can have a look, do you an idea where to start?
In init_device()
, update_dcb()
and all that.
Please remind me what I need to do to use symbols in FDPP? I'm doing
(gdb) p * (dhp*) &lowmem_base[(dhp.ptr.seg<<4)+dhp.ptr.off]
A syntax error in expression, near `) &lowmem_base[(dhp.ptr.seg<<4)+dhp.ptr.off]'.
I think there's some knob in FDPP build I need to tweak?
EXTRA_DEBUG=1
Thanks, that's great.
Interesting driver btw. But I hate adding anything that is not going to be in the default config/autoexec. It will rot.
Yes, I'd hoped the driver would be faster than MFS, but as it's not there's no point in adding it.
Any progress?
I got distracted, will have another look tomorrow.
Could you please attach pre-built binary?
I could, but it won't load without its dosemu doshelper routine in place. You'd be better off checking out my emudsk01-sys branch.
OK then, waiting for your another look tomorrow. :) Its too late here already anyway.
This can be reproduced using devel, with the xmsdsk.exe loaded from fdppconfig.sys as a device
lastdrive=Z
device=dosemu\emufs.sys /tmp
device=dosemu\ems.sys
device=xmsdsk.exe 8000
C: HD1, Pri[ 1], CHS= 0-1-1, start= 0 MB, size= 10 MB
D: HD2, Pri[ 1], CHS= 0-1-1, start= 0 MB, size= 2000 MB
E: HD3, Pri[ 1], CHS= 0-1-1, start= 0 MB, size= 2000 MB
F: HD4, Pri[ 1], CHS= 0-1-1, start= 0 MB, size= 2000 MB
EMUFS host file and print access available
dosemu XMS 3.0 & UMB support enabled
dosemu EMS driver rev 0.8 installed.
*** XMS RAMdisk v1.9I (FU - 08/98): Installed as drive G:.
Process 0 starting: C:\command.com /P /E:256
FreeCom version 0.84-pre2 XMS_Swap [Aug 28 2006 00:29:00]
C:\>prompt $P$G
C:\>path c:\bin;c:\gnu;c:\dosemu
C:\>unix -s DOSEMU_VERSION
UNIX: option -s is deprecated, use system.com instead
C:\>unix -e
UNIX: option -e is deprecated, use system.com instead
C:\>dir g:
File not found. - 'g:'
C:\>g:
Invalid drive G:.
C:\>
(C) Copyright 1995-2006 Pasquale J. Villani and The FreeDOS Project.
All Rights Reserved. This is free software and comes with ABSOLUTELY NO
WARRANTY; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 2, or (at your option) any later version.
C: HD1, Pri[ 1], CHS= 0-1-1, start= 0 MB, size= 10 MB
D: HD2, Pri[ 1], CHS= 0-1-1, start= 0 MB, size= 2000 MB
E: HD3, Pri[ 1], CHS= 0-1-1, start= 0 MB, size= 2000 MB
F: HD4, Pri[ 1], CHS= 0-1-1, start= 0 MB, size= 2000 MB
EMUFS host file and print access available
dosemu XMS 3.0 & UMB support enabled
dosemu EMS driver rev 0.8 installed.
*** XMS RAMdisk v1.9I (FU - 08/98): Installed as drive G:.
FreeCom version 0.84-pre2 XMS_Swap [Aug 28 2006 00:29:00]
C:\>prompt $P$G
C:\>path c:\bin;c:\gnu;c:\dosemu
C:\>unix -s DOSEMU_VERSION
UNIX: option -s is deprecated, use system.com instead
C:\>unix -e
UNIX: option -e is deprecated, use system.com instead
C:\>g:
G:\>
Are you looking into that yourself? :)
To be honest I'm finding it difficult and I'm about to run out of time for today.
Yeah, sometimes I am asking myself if debugging fdpp with gdb is any easier than debugging freedos with dosdebug. Though as I have never done the later, I don't know the answer.
I see it trying to add the new device to the DPBs, but for some reason it doesn't appear on the end (this is before the CDS and DPB relocation to final location at the end of config.sys processing).
Does this line make sense in an FDPP world? https://github.com/stsp/fdpp/blob/61dc2e70bf857c96365393c58246968765ec3987/kernel/main.c#L559
It should, there are lots of ptr arithmetic around.
I see this
(gdb) p/x LoL->_CDSp[0].cdsDpb
$32 = {ptr = {off = 0x19e8, seg = 0xd9}}
(gdb) p/x LoL->_CDSp[1].cdsDpb
$33 = {ptr = {off = 0x1a25, seg = 0xd9}}
(gdb) p/x LoL->_CDSp[2].cdsDpb
$34 = {ptr = {off = 0x1a62, seg = 0xd9}}
(gdb) p/x LoL->_CDSp[3].cdsDpb
$35 = {ptr = {off = 0x1a9f, seg = 0xd9}}
(gdb) p/x LoL->_CDSp[4].cdsDpb
$36 = {ptr = {off = 0x1adc, seg = 0xd9}}
(gdb) p/x LoL->_CDSp[5].cdsDpb
$37 = {ptr = {off = 0x1b19, seg = 0xd9}}
(gdb) p/x LoL->_CDSp[6].cdsDpb
$38 = {ptr = {off = 0x0, seg = 0x2d4}}
Then with my tweaked dosdebug
dosdebug> dpbs 00d9:1b19
dosdebug>
DPBs (compiled for DOS v4+ format)
00D9:1B19 (F:)
driver unit: 5
bytes_per_sect = 0x0
last_sec_in_clust = 0x0
sec_shift = 0x0
reserv_secs = 0x0
num_fats = 0x0
root_ents = 0x0
data_start = 0x0
max_clu = 0x0
sects_per_fat = 0x0
first_dir_off = 0x0
device driver = 0070:0618
media_id = 0x0
accessed = 0xff
next_DPB = FFFF:FFFF
first_free_clu = 0x0
fre_clusts = 0x0
dosdebug> dpbs 02d4:0000
dosdebug>
DPBs (compiled for DOS v4+ format)
02D4:0000 (G:)
driver unit: 0
bytes_per_sect = 0x0
last_sec_in_clust = 0x0
sec_shift = 0x0
reserv_secs = 0x0
num_fats = 0x0
root_ents = 0x0
data_start = 0x0
max_clu = 0x0
sects_per_fat = 0x0
first_dir_off = 0x0
device driver = 02B2:0000
media_id = 0x0
accessed = 0xff
next_DPB = FFFF:FFFF
first_free_clu = 0x0
fre_clusts = 0x0
See that the next pointer of F: is still 0xfffffff
BTW is there any way to just service dosdebug requests when stopped in gdb, as I find myself having to queue up a dosdebug command, then 'next' in gdb until it's been serviced?
I have to stop on this for today now, so feel free to fix it :smile:. I've pushed my dosdebug tweak in https://github.com/andrewbird/dosemu2/tree/dosdebug-39 if you need it.
So if you inspect _dpb->dpb_next
right after
it was changed, do you still see that?
You can do that with the lowmem_base
printing trick.
Thanks for pointing to this place, the bug was just 5 lines above. :) You saved me a debugging time. Please see how your driver works. xmsdsk still doesn't, so you can continue this quest. :)
That fix worked well, early dpb chain looks good now
00D9:1B19 (F:)
driver unit: 5
bytes_per_sect = 0x0
last_sec_in_clust = 0x0
sec_shift = 0x0
reserv_secs = 0x0
num_fats = 0x0
root_ents = 0x0
data_start = 0x0
max_clu = 0x0
sects_per_fat = 0x0
first_dir_off = 0x0
device driver = 0070:0618
media_id = 0x0
accessed = 0xff
next_DPB = 02D4:0000
first_free_clu = 0x0
fre_clusts = 0x0
02D4:0000 (G:)
driver unit: 0
bytes_per_sect = 0x0
last_sec_in_clust = 0x0
sec_shift = 0x0
reserv_secs = 0x0
num_fats = 0x0
root_ents = 0x0
data_start = 0x0
max_clu = 0x0
sects_per_fat = 0x0
first_dir_off = 0x0
device driver = 02B2:0000
media_id = 0x0
accessed = 0xff
next_DPB = FFFF:FFFF
first_free_clu = 0x0
fre_clusts = 0x0
I guess that's uncovered something else as XMSDISK installation is now hanging, is that what you see?
I see the crash. Does your driver now work?
I just checked,yes it loads and G: is functional.
G:\>c:\iostoned
Wait - IOSTONE is performing disk IO with varying blocksizes.
Total elapsed time is 20 sec.
Files were opened 9504 times. 15579 kb was read, and 7461 kb written.
Average read/write troughput was 1152 kb/sec, including open/close overhead.
This machine benchmarks at 100000 iostones/sec.
G:\>c:\iostoned
Wait - IOSTONE is performing disk IO with varying blocksizes.
Total elapsed time is 20 sec.
Files were opened 9504 times. 15579 kb was read, and 7461 kb written.
Average read/write troughput was 1152 kb/sec, including open/close overhead.
This machine benchmarks at 100000 iostones/sec.
G:\>
I think we can close this ticket now, thanks.
BTW XMSDSK crashes both FreeDOS and FDPP (ISTR MS-DOS 6.22 is okay) when loaded as an exe from the command line, so there's probably some unrelated incompatibility in there.
From the command line? But we load it from device= line, no?
Yes, that's one of those funky dual mode drivers.
So we load it from device=. In this case it doesn't matter that it crashes "when loaded as an exe from the command line". So why it is not a bug that in fdpp it crashes even with device=?
It's not directly related to this ticket as XMSDSK was a secondary example to avoid using an experimental driver, so that's why I closed it. But I suppose that even though it's generally not great on FreeDOS it's still not right that loading with FDPP crashes.
Exactly. It works perfectly under freedos with device=.
Chasing this down, it seems the crash occurs in InitializeAllBPBs()
when trying to open a non existent file on G:
, that should be okay as it worked for all the preceding drives. open
is defined to init_DosOpen()
but I don't seem to be able to find the source for that, where should I look?
In asm files. Another thing to check is if maybe its called after init_text is being purged (something not done in freedos, I added purge to catch bugs)
Though if it was done for other drives in the same call, then its definitely not purged.
So I end up in dosdebug tracing kernel code. After a while I see a suspicious return to what looks like uninitialized data
dosdebug>
dosdebug>
system state: stopped
AX=0003 BX=0008 CX=02b2 DX=03ca SI=0000 DI=0001 SP=039e BP=039e
DS=00d9 ES=0060 FS=0000 GS=0000 FL=000a3346
CS:IP=078b:03aa SS:SP=00d9:039e
078b:03aa 5F pop di
dosdebug>
dosdebug>
system state: stopped
AX=0003 BX=0008 CX=02b2 DX=03ca SI=0000 DI=f800 SP=03a0 BP=039e
DS=00d9 ES=0060 FS=0000 GS=0000 FL=000a3346
CS:IP=078b:03ab SS:SP=00d9:03a0
078b:03ab 5E pop si
dosdebug>
dosdebug>
system state: stopped
AX=0003 BX=0008 CX=02b2 DX=03ca SI=0ca7 DI=f800 SP=03a2 BP=039e
DS=00d9 ES=0060 FS=0000 GS=0000 FL=000a3346
CS:IP=078b:03ac SS:SP=00d9:03a2
078b:03ac 5D pop bp
dosdebug>
dosdebug>
system state: stopped
AX=0003 BX=0008 CX=02b2 DX=03ca SI=0ca7 DI=f800 SP=03a4 BP=02fa
DS=00d9 ES=0060 FS=0000 GS=0000 FL=000a3346
CS:IP=078b:03ad SS:SP=00d9:03a4
078b:03ad C3 ret
dosdebug>
dosdebug>
system state: stopped
AX=0003 BX=0008 CX=02b2 DX=03ca SI=0ca7 DI=f800 SP=03a6 BP=02fa
DS=00d9 ES=0060 FS=0000 GS=0000 FL=000a3346
CS:IP=078b:0001 SS:SP=00d9:03a6
078b:0001 0000 add [bx+si],al
dosdebug>
dosdebug>
system state: stopped
AX=0003 BX=0008 CX=02b2 DX=03ca SI=0ca7 DI=f800 SP=03a6 BP=02fa
DS=00d9 ES=0060 FS=0000 GS=0000 FL=000a3306
CS:IP=078b:0003 SS:SP=00d9:03a6
078b:0003 0000 add [bx+si],al
Any idea how I can convert memory addresses in kernel.map file to seg:ofs so I could have symbols?
kernel.map is quite easily convertible to seg:off. There are load addresses to which you can add 0x600 (our load address) to match the dosdebug address.
Also you can use -D9+f
to see in the log what
freedos functions are being called. Seeing the
last func before crash, may give some clue.
Also you can breakpoint the do_asm_call
func
and see the stacktrace on every call. The last
one before crash would be very very useful.
0x600 (our load address) to match the dosdebug address.
Not quite. The relocation also happens.
After adding 0x60 to segment, you need to
see the -D9+f
log to check if that segment
was relocated. If so, it is printed there, and
you see its new value.
I think I'm going to work on adding the dosdebug symbol relocation you asked for.
BTW do you think it would be possible to run the mhpdbg stuff in a separate thread, as I stumbled across this gdb reference.
In gdb you usually can do call
or print
and call any target function w/o involving
any threads. So you can just queue some
dosdebug commands in the pipe and then
call mhp_pool
perhaps or something like
that with gdb. Haven't tried this myself, but
looks much easier than involving threads.
Symbol relocation would be nice, but I wonder if this particular bug needs it that badly. :)
So you can just queue some dosdebug commands in the pipe and then call mhp_pool perhaps or something like that with gdb.
That's interesting, I didn't know that was possible.
Symbol relocation would be nice, but I wonder if this particular bug needs it that badly. :)
Probably not, but I'm doing that to avoid finding the bug :)
Probably not, but I'm doing that to avoid finding the bug :)
Deal. :)
So in gdb things like p foo(2)
usually work fine.
I don't even know why the one would use call
if print
just works unless foo
returns void
.
Works even when foo
returns void
it seems.
cool!
The crash happens in CriticalError()
fn.
To reproduce it w/o any extra drivers, the
one can just type a:
to provoke the critical
error.
Sigh. This is definitely a critical error in fdpp. :)
And of course when we fix CriticalError()
to not crash, we will return back to see why
that driver causes the critical error under fdpp...
Added #88
So the crash is gone, but the unavailable g: is still there
After installing a block device driver with
device=emudsk.sys
the drive is unavailable under FDPP, but is fine under FreeDOSCurrent FDPP
You can see that the driver is loaded as G:
Device driver was loaded okay and remains resident in memory
CDS entry seems to have the flags zeroed
And DPB for drive G: is missing
Now FreeDOS