Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
06693 Misc. Critical (emulation) Always Oct 1, 2017, 00:17 Jun 22, 2019, 12:27
Tester SeanRamey View Status Public Platform MAME (Official Binary)
Assigned To Resolution Open OS Windows 10 (64-bit)
Status [?] Acknowledged Driver
Version 0.190 Fixed in Version Build 64-bit
Fixed in Git Commit Github Pull Request #
Summary 06693: imgtool: imgtool.exe will crash or give "Unexpected error" or loops endlessly upon attempting to create certain formats of image files
Description Note: I didn't test every format, but here are the ones that I did test, and failed.

When attempting to create an image for the following formats imgtool.exe will CRASH :
pc_dsk_fat
dsk_fat
dsk_mac_hfs
dsk_os9
dsk_prodos_525
dsk_rsdos
dsk_vzdos
fdi_bml3
fdi_fat
fdi_mac_hfs
fdi_mac_mfs
fdi_os9
fdi_prodos_35
fdi_prodos_525
fdi_rsdos
fdi_vzdos
td0_bml3
td0_fat
td0_mac_hfs
td0_mac_mfs
td0_os9
td0_prodos_35
td0_prodos_525
td0_rsdos
td0_vzdos
cqm_bml3
cqm_fat
cqm_mac_mfs
cqm_os9
cqm_prodos_35
cqm_prodos_525

When attempting to create an image for the following formats imgtool.exe will LOOP ENDLESSLY AND USE 100% OF A SINGLE CPU CORE :
imd_bml3
imd_fat
imd_mac_hfs
imd_mac_mfs
imd_os9
imd_prodos_35
imd_prodos_525
imd_vzdos

When attempting to create an image for the following formats imgtool.exe will PRINT "UNEXPECTED ERROR" :
mess_hd
pc_chd
cqm_vzdos

When attempting to create an image for the following formats imgtool.exe will PRINT "CORRUPT IMAGE" :
cqm_mac_hfs

Imgtool.exe seems to have never worked. Mess v0.160b was the first to include imgtool.exe and the exact same bug still exists.
OLD: Please tell me that I'm doing something wrong. I don't see how anybody could have missed these huge issues. At this point, imgtool is almost completely broken.
Steps To Reproduce Run imgtool.exe from the command line with the arguments "create <format> <filename>"
Ex: imgtool create pc_chd testfile
Additional Information I've created a Windows batch file that automatically executes all the mentioned commands for testing use. You will need to rename it with the ".bat" extension since I'm not allowed to upload ".bat" files apparently.
Github Commit
Flags
Regression Version 0.160
Affected Sets / Systems imgtool
Attached Files
txt file icon imgtool_test.txt (1,687 bytes) Oct 1, 2017, 00:17 Uploaded by SeanRamey
[Show Content]
Relationships
There are no relationship linked to this issue.
Notes
6
User avatar
No.14316
star2root
Viewer
Oct 22, 2017, 14:24
Do you happen to know what the last version was were at least one of these formats worked?
User avatar
No.14399
SeanRamey
Tester
Nov 2, 2017, 08:16
I tried quite a few of these going back in some pretty old versions, until I hit a version were imgtool.exe wasn't included, which is mess 0.159b. It seems that these have never worked. Mess 0.160b was the first version with imgtool.exe and it has the exact same bugs. Seems that somebody never tested it, or it just wasn't ever finished in the first place.
User avatar
No.14400
SeanRamey
Tester
Nov 2, 2017, 08:21
Also, I think I will change the severity of this to Critical (emulation) since the program crashes or hangs, and it is separate from Mame.exe, and it is definitely needed to fully emulate some systems.
User avatar
No.14401
wuemura
Viewer
Nov 2, 2017, 11:07
(gdb) run create dsk_fat test
Starting program: /home/mame/Downloads/mame/imgtool create dsk_fat test
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
dsk_dsk_construct (floppy=0x5555559894a0, format=<optimized out>, 
    params=<optimized out>) at ../../../../../src/lib/formats/dsk_dsk.cpp:256
256				tmp += header[0x34 + i] << 8;
(gdb) bt
#0  dsk_dsk_construct (floppy=0x5555559894a0, format=<optimized out>, 
    params=<optimized out>) at ../../../../../src/lib/formats/dsk_dsk.cpp:256
#1  0x00005555555e558a in floppy_create (fp=fp@entry=0x555555972d00, 
    procs=procs@entry=0x555555944560 <imgtool_ioprocs>, 
    format=format@entry=0x555555948ff8 <floppyoptions_pc+280>, 
    parameters=parameters@entry=0x0, outfloppy=outfloppy@entry=0x555555972d30)
    at ../../../../../src/lib/formats/flopimg.cpp:238
#2  0x0000555555575be2 in imgtool_floppy_create(imgtool::image &, <unknown type in /home/mame/Downloads/mame/imgtool, CU 0x55a4b, DIE 0x66700>, util::option_resolution *) (image=..., 
    stream=<unknown type in /home/mame/Downloads/mame/imgtool, CU 0x55a4b, DIE 0x66700>, opts=0x0) at ../../../../../src/tools/imgtool/iflopimg.cpp:181
#3  0x000055555557bc85 in imgtool::image::internal_open (
    outimg=<synthetic pointer>std::unique_ptr<imgtool::image> containing <optimized out>, createopts=0x0, read_or_write=3, filename=..., module=0x5555559763d0)
    at ../../../../../src/tools/imgtool/imgtool.cpp:1009
#4  imgtool::image::create (
    image=<synthetic pointer>std::unique_ptr<imgtool::image> containing <optimized out>, opts=0x0, filename=..., module=0x5555559763d0)
    at ../../../../../src/tools/imgtool/imgtool.cpp:1102
#5  imgtool::image::create (module=0x5555559763d0, filename=..., 
    opts=<optimized out>) at ../../../../../src/tools/imgtool/imgtool.cpp:1130
#6  0x0000555555589a9c in cmd_create (c=0x555555944680 <cmds>, 
---Type <return> to continue, or q <return> to quit---
    argc=<optimized out>, argv=0x7fffffffdca0)
    at ../../../../../src/tools/imgtool/main.cpp:597
#7  0x00005555555706fa in main (argc=4, argv=0x7fffffffdc90)
    at ../../../../../src/tools/imgtool/main.cpp:910
(gdb) list +
251			tag->disk_image_type = 1;
252			tmp = 0x100;
253			for (i=0; i<tag->tracks * tag->heads; i++)
254			{
255				tag->track_offsets[cnt] = tmp;
256				tmp += header[0x34 + i] << 8;
257				cnt += skip;
258			}
259		}
260
User avatar
No.16406
shattered
Tester
May 2, 2019, 20:26
imgtool should not attempt to create dsk_*, fdi_*, td0_*, cqm_* and imd_* -- those floppy image formats are read-only (supports_save = false).

pc_chd tries to open already opened CHD, but removing the second open call makes it crash:
SUMMARY: AddressSanitizer: heap-use-after-free ../../../../../src/tools/imgtool/stream.cpp:86 in imgtool::stream::~stream()

I think I have a fix for mess_hd and pc_dsk_fat. PR coming soon.

There are more issues in imgtool and its modules, though:
- cannot put (write) multiple files into disk image
- fails to identify an image created by itself (apple35_raw_mac_mfs, apple2_do_prodos_525, maybe more)
- fails to identify an image with non-standard extension
- may fail to identify an image without extension (crash)
User avatar
No.16581
shattered
Tester
Jun 22, 2019, 12:27
https://github.com/mamedev/mame/pull/5136 was merged, mess_hd now works. Others require more work (building imgtool with SANITIZE=address points out various problems).