saramibreak / DiscImageCreator

This is the disc (CD, GD, DVD, HD-DVD, BD, GC/Wii, XBOX, XBOX 360) and disk (Floppy, MO, USB etc) image creation tool
http://forum.redump.org/topic/10483/discimagecreator/
Apache License 2.0
513 stars 45 forks source link

Segmentation fault when attempting to dump several audio CDs with code from the test branch, Fedora Linux 38. #227

Closed TheMuso closed 9 months ago

TheMuso commented 10 months ago

I am wanting to use DiscImageCreator to get more accurate dumps of audio CDs.

Particulars: DiscImageCreator version: Test branch, commit 8c138d71cf5444f0e08c04d0dca9e82bd5c0201b, built with debugging enabled. Fedora Linux 38 Kernel 6.4.12 gcc 13.2.1 glibc 2.37 Optical drive: HL-DT-ST BD-RE BH16NS55, 1.02, N000200SIK92G9OF211 Command-line arguments: cd /dev/sr0 Sun_Is_Shining 0 /c2

This happens with several audio CDs. Tested with 3 CD singles, and 1 album length CD. Some console output from one of the CD singles is below, but with all of them, the segfault happens when the dumping process is close to the end of the disc.

Here is a backtrace taken with gdb.

0 0x00007ffff7b7cf81 in __memmove_avx_unaligned () from /lib64/libc.so.6

1 0x000000000041b193 in ReadCDAll (pExecType=0x7fffffffe29c, pExtArg=0x7fffffffd1c0, pDevice=0x7fffffffaf50, pDisc=0x7fffffffb000,

pDiscPerSector=0x7fffffff9c70, c2=_CDFLAG::_READ_CD::byte294, pszPath=0x7fffffffc1c0 "/var/home/themuso/temp/Sun_Is_Shining.bin", fpCcd=0x577550, 
fpC2=0x56ef60) at execScsiCmdforCD.cpp:1131

2 0x0000000000408c0d in execForDumping (pExecType=0x7fffffffe29c, pExtArg=0x7fffffffd1c0,

pszFullPath=0x7fffffffc1c0 "/var/home/themuso/temp/Sun_Is_Shining.bin", pDevice=0x7fffffffaf50, pDisc=0x7fffffffb000) at DiscImageCreator.cpp:362

3 0x0000000000409d6a in exec (argv=0x7fffffffe3f8, pExecType=0x7fffffffe29c, pExtArg=0x7fffffffd1c0,

pszFullPath=0x7fffffffc1c0 "/var/home/themuso/temp/Sun_Is_Shining.bin") at DiscImageCreator.cpp:594

4 0x000000000040ee18 in main (argc=6, argv=0x7fffffffe3f8) at DiscImageCreator.cpp:2016

Console output from DiscImageCreator, copied and pasted from the gdb session: Starting program: /var/home/themuso/.local/bin/DiscImageCreator cd /dev/sr0 Sun_Is_Shining 0 /c2 [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". AppVersion 64 bit, AnsiBuild, 20230829T184016 /c2 val1 was omitted. set [4000] /c2 val2 was omitted. set [0] /c2 val3 was omitted. set [0] /c2 val4 was omitted. set [0] valid extension was omitted. -> set .bin CurrentDirectory /var/home/themuso/temp WorkingPath Argument: Sun_Is_Shining.bin FullPath: /var/home/themuso/temp/Sun_Is_Shining.bin Drive: / Directory: var/home/themuso/temp/ Filename: Sun_Is_Shining Extension: .bin StartTime: 2023-08-29T18:40:58+1000 Block Size: 4096 Flagment Size: 4096 All Block Num: 125022806 Free Block Num: 91961419 Available Block Num: 90263677 I Node Num: 0 Free I Node Num: 0 Available I Node Num: 0 File System ID: 3637646059194057689 Mount Flag: 4096 Max Filename Length: 255 DiskSize of [/var/home/themuso/temp] Total: 512093413376 bytes Used: 135419441152 bytes

Space:   376673972224 bytes
 => There is enough disk space for dumping

This drive (BD-RE BH16NS55 1.02 N000200SIK92G9OF211 ) can read data sectors at scrambled state [OpCode: 0xbe, C2flag: 1, SubCode: 1] This drive (BD-RE BH16NS55 1.02 N000200SIK92G9OF211 ) can read data sectors at scrambled state [OpCode: 0xbe, C2flag: 1, SubCode: 2] This drive (BD-RE BH16NS55 1.02 N000200SIK92G9OF211 ) can read data sectors at scrambled state [OpCode: 0xbe, C2flag: 1, SubCode: 4] Checking SubQ adr (Track) 5/ 5 Checking reading lead-out -> OK Checking SubRtoW (Track) 5/ 5 Set OpCode: 0xbe, SubCode: 1(Raw) Checking SubQ ctl (Track) 5/ 5 Creating .scm (LBA) 130860/130870 Program received signal SIGSEGV, Segmentation fault.

Sun_Is_Shining_20230829T184016.txt Sun_Is_Shining_c2Error.txt Sun_Is_Shining_disc.txt Sun_Is_Shining_drive.txt Sun_Is_Shining_mainError.txt Sun_Is_Shining_mainInfo.txt Sun_Is_Shining_subError.txt Sun_Is_Shining_subInfo.txt Sun_Is_Shining_subReadable.txt Sun_Is_Shining_volDesc.txt

saramibreak commented 10 months ago

Do you have a CD with data track(s)? If yes, try to dump it and check if the drive reads the lead-out, please.

TheMuso commented 10 months ago

Tested with a CD with a data track, and a mixed mode CD. Logs attached, both completed successfully. console-data-cd.log console-mixed-mode.log

TheMuso commented 10 months ago

I decided to try another data CD, and this time, it segfaulted again.

gdb) run cd /dev/sr0 data-cd 0 /c2 Starting program: /var/home/themuso/.local/bin/DiscImageCreator cd /dev/sr0 data-cd 0 /c2 [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". AppVersion 64 bit, AnsiBuild, 20230829T184016 /c2 val1 was omitted. set [4000] /c2 val2 was omitted. set [0] /c2 val3 was omitted. set [0] /c2 val4 was omitted. set [0] valid extension was omitted. -> set .bin CurrentDirectory /var/home/themuso/temp WorkingPath Argument: data-cd.bin FullPath: /var/home/themuso/temp/data-cd.bin Drive: / Directory: var/home/themuso/temp/ Filename: data-cd Extension: .bin StartTime: 2023-08-30T12:04:45+1000 Block Size: 4096 Flagment Size: 4096 All Block Num: 125022806 Free Block Num: 91996634 Available Block Num: 90298124 I Node Num: 0 Free I Node Num: 0 Available I Node Num: 0 File System ID: 3637646059194057689 Mount Flag: 4096 Max Filename Length: 255 DiskSize of [/var/home/themuso/temp] Total: 512093413376 bytes Used: 135275200512 bytes

Space:   376818212864 bytes
 => There is enough disk space for dumping

This drive (BD-RE BH16NS55 1.02 N000200SIK92G9OF211 ) can read data sectors at scrambled state [OpCode: 0xbe, C2flag: 1, SubCode: 0] This drive (BD-RE BH16NS55 1.02 N000200SIK92G9OF211 ) can read data sectors at scrambled state [OpCode: 0xbe, C2flag: 1, SubCode: 1] This drive (BD-RE BH16NS55 1.02 N000200SIK92G9OF211 ) can read data sectors at scrambled state [OpCode: 0xbe, C2flag: 1, SubCode: 2] This drive (BD-RE BH16NS55 1.02 N000200SIK92G9OF211 ) can read data sectors at scrambled state [OpCode: 0xbe, C2flag: 1, SubCode: 4] Checking SubQ adr (Track) 47/47 Checking reading lead-out -> OK Checking SubRtoW (Track) 47/47 Reading DirectoryRecord 1/ 1 Set OpCode: 0xbe, SubCode: 1(Raw) Checking SubQ ctl (Track) 47/47 Creating .scm (LBA) 164351/164364 Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7b7cf81 in __memmove_avx_unaligned () from /lib64/libc.so.6 Missing separate debuginfos, use: dnf debuginfo-install glibc-2.37-4.fc38.x86_64 libgcc-13.2.1-1.fc38.x86_64 libstdc++-13.2.1-1.fc38.x86_64 (gdb) bt

0 0x00007ffff7b7cf81 in __memmove_avx_unaligned () from /lib64/libc.so.6

1 0x000000000041b193 in ReadCDAll (pExecType=0x7fffffffe28c, pExtArg=0x7fffffffd1b0, pDevice=0x7fffffffaf40, pDisc=0x7fffffffaff0,

pDiscPerSector=0x7fffffff9c60, c2=_CDFLAG::_READ_CD::byte294, pszPath=0x7fffffffc1b0 "/var/home/themuso/temp/data-cd.bin", fpCcd=0x5b0640, fpC2=0x56f480)
at execScsiCmdforCD.cpp:1131

2 0x0000000000408c0d in execForDumping (pExecType=0x7fffffffe28c, pExtArg=0x7fffffffd1b0, pszFullPath=0x7fffffffc1b0 "/var/home/themuso/temp/data-cd.bin",

pDevice=0x7fffffffaf40, pDisc=0x7fffffffaff0) at DiscImageCreator.cpp:362

3 0x0000000000409d6a in exec (argv=0x7fffffffe3e8, pExecType=0x7fffffffe28c, pExtArg=0x7fffffffd1b0,

pszFullPath=0x7fffffffc1b0 "/var/home/themuso/temp/data-cd.bin") at DiscImageCreator.cpp:594

4 0x000000000040ee18 in main (argc=6, argv=0x7fffffffe3e8) at DiscImageCreator.cpp:2016

data-cd_20230829T184016.txt data-cd_c2Error.txt data-cd_disc.txt data-cd_drive.txt data-cd_mainError.txt data-cd_mainInfo.txt data-cd_subError.txt data-cd_subInfo.txt data-cd_volDesc.txt

saramibreak commented 10 months ago

Checking reading lead-out -> OK

It seems "BH16NS55 1.02" can read the lead-out without 0xF1.

Uploaded. DiscImageCreator_test.zip

EDIT: Sorry It's a windows build.

Please comment out L180 of the check.cpp and rebuild it yourself. https://github.com/saramibreak/DiscImageCreator/blob/master/DiscImageCreator/check.cpp#L180

TheMuso commented 10 months ago

Would you mind pushing your source code changes to a pull request or branch so I can build and test locally on linux?

As per your comment about the drive I am using and reading the lea-dout, I am not entirely sure I agree with that assessment. The drive is currently connected via SATA connection, and is mounted in my desktop tower. I previously tried to use DiscImageCreator with the drive connected via a USB to SATA adapter. I remember seeing console messages stating that the lead-out couldn't be read, but the drive supported the 0X1F opcode. However, the dump failed with some other SCSI messages. This is what prompted me to connect the drive and mount it internally.

To help resolve this problem properly, I will re-dump the discs I have tested with, complete with more information on what CDs they are, and do so via direct SATA connection, as well as with the few SATA to USB adapters I have around here. I'll get back to you with a zip file with all logged data.

saramibreak commented 10 months ago

I previously tried to use DiscImageCreator with the drive connected via a USB to SATA adapter. I remember seeing console messages stating that the lead-out couldn't be read

Umm, it's weird. Surely your drive can read the lead-out without using 0xF1. As a side note, BW-16D1HT and BC-12D2HT can't read the lead-out without using 0xF1.

TheMuso commented 9 months ago

Sorry it has taken me so long to get back to you.

Through further testing, I found that this problem occurs with a specific SATA controller on my system. I have 2. The chipset SATA controller, which is AMD, and an ASMedia SATA controller. I had the drive plugged into the ASMedia controller. I have since run tests on both, with differing results. The segmentation faults occur with the ASMedia controller on Linux, but not in Windows. Everything works fine on the AMD SATA controller.

Zipped logs atatched. Advanced Micro Devices, Inc. [AMD] 400 Series Chipset SATA Controller (rev 01) - Linux.tar.gz Advanced Micro Devices, Inc. [AMD] 400 Series Chipset SATA Controller (rev 01) - Windows.tar.gz ASMedia Technology Inc. ASM1062 Serial ATA Controller (rev 02) - Linux.tar.gz ASMedia Technology Inc. ASM1062 Serial ATA Controller (rev 02) - Windows.tar.gz

saramibreak commented 9 months ago

Sorry it has taken me so long to get back to you.

Thanks for the precious report. Updated test branch. (https://github.com/saramibreak/DiscImageCreator/commit/9e4686b21adde870b413bd684b715b7286826886)

TheMuso commented 9 months ago

Can verify that I am no longer getting crashes with the original CD I was dumping when I originally filed this report using the ASMedia controller. Thanks.

mirh commented 7 months ago

via a USB to SATA adapter.

What chip does your adapter use? There are many half-assed ones without UAS, or at least with bugged firmware. Maybe there's some usb-storage.quirk that could help.

The segmentation faults occur with the ASMedia controller on Linux, but not in Windows.

Meaning instead.. that it works good in windows? In that case you could open a bug report for the IO/Storage guys.