CHDMAN: creating delta chd using parent chd with large size and small hunk will report error
MAME version
0.271 , 0.272 , 0.273, , ,
System information
Win10 22h2 , AMD zen4 7840HS
Incorrect behaviour
In some cases,creating delta chd using parent chd with large size and small hunk will report error:
CHD error occurred: Hunk out of range Error during compression: Hunk out of range Fatal error occurred: 1
But when I changed chdman back to 0.270, the compression went smoothly.
Expected behaviour
compression went smoothly like 0.270
Steps to reproduce
1, specify the hunk size as 2048 to make chd file. for example: chdman createdvd -c zstd,flac,huff,lzma -hs 2048 -i "Soulcalibur III (Japan) (En,Ja) (v2.00).chd" -o "ori.chd" 2,Modify some data on the original iso (e.g. simply modify a few bytes). Then create a delta for the parent using the previous chd. for example: chdman createdvd -i "modded.iso" -op "ori.chd" -o "new.chd"
Additional details
I tested several larger iso that exhibited the problem: Soulcalibur III (Japan) (En,Ja) (v2.00).iso Berserk - Millennium Falcon-hen - Seima Senki no Shou (Japan).iso
In addition, the earliest problematic commit that can be traced back is this https://github.com/mamedev/mame/commit/43584224ebb63b6fbc6c01c9e5cc0d4b36ed6366
How big do the files have to be to observe this behaviour?
When the iso size exceeds 4G and use 2048 hunk size. You can try the ps2 iso in your hand, and it is very likely that this issue can be reproduced.
The underlying issue that it wants to get away with reading past the end if the parent CHD was there before 0.270, but it just didn’t check for errors reading the parent CHD at all. Adding error checking exposed it.
Fixing it properly is going to require more effort, but 65c263749e1fbc24fe97a1d0fb198b4fd04023c7 hacks around the issue by ignoring that specific error in that situation.
Not exactly. Even if the parent chd is made with the latest 0.275, the outcome will be the same.However I tested the latest build and the issue seems to have been temporarily resolved.