cth103 / libdcp

Library for reading and writing Digital Cinema Packages (DCPs).
GNU General Public License v2.0
22 stars 11 forks source link

read_dcp: segfaults with a DCP which does contain a sound reel; works with a DCP which doesn't contain a sound reel #9

Closed geor-g closed 1 year ago

geor-g commented 1 year ago

Hi Carl,

first things first: thanks so much for building and maintaining libdcp and friends -- highly appreciated!

Some information regarding my environment:

/usr/local/src/libcxml$ git log HEAD --oneline --no-walk
f29b074 (HEAD -> master, tag: 00.17.0, origin/master, origin/HEAD) Fix formatting of versions in .pc files (they were being written as b'0.1.2')
/usr/local/src/asdcplib$ git log HEAD --oneline --no-walk
ae75eb4 (HEAD -> carl, origin/carl) Fix writing of versions to .pc files.
/usr/local/src/libdcp$ git log HEAD --oneline --no-walk
76ff8c70 (HEAD -> main, origin/main, origin/HEAD) Remove old jpeg option reference in cscript.
$ cat /etc/os-release | head -n 1
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
/usr/local/src/ImageMagick$ git log HEAD --oneline --no-walk
fe219dc96 (HEAD -> main, origin/main, origin/HEAD) latest documentation
$ apt list --installed | grep -e g++ -e libboost -e libxml -e openssl -e sndfile -e xerces-c

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

g++-10/stable,now 10.2.1-6 amd64 [installed,automatic]
g++/stable,now 4:10.2.1-1 amd64 [installed,automatic]
libboost-date-time1.74-dev/stable,now 1.74.0-9 amd64 [installed]
libboost-date-time1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-filesystem1.74-dev/stable,now 1.74.0-9 amd64 [installed]
libboost-filesystem1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-iostreams1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-locale1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-log1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-nowide1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-program-options1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-regex1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-serialization1.74-dev/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-serialization1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-system1.74-dev/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-system1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-test1.74-dev/stable,now 1.74.0-9 amd64 [installed]
libboost-test1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-thread1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost1.74-dev/stable,now 1.74.0-9 amd64 [installed]
libgnutls-openssl27/stable,stable-security,now 3.7.1-5+deb11u2 amd64 [installed,automatic]
libsndfile1-dev/stable,now 1.0.31-2 amd64 [installed]
libsndfile1/stable,now 1.0.31-2 amd64 [installed,automatic]
libxerces-c-dev/stable,now 3.2.3+debian-3 amd64 [installed]
libxerces-c3.2/stable,now 3.2.3+debian-3 amd64 [installed]
libxml++2.6-2v5/stable,now 2.40.1-3 amd64 [installed]
libxml++2.6-dev/stable,now 2.40.1-3 amd64 [installed]
libxml2-dev/stable-security,now 2.9.10+dfsg-6.7+deb11u3 amd64 [installed,automatic]
libxml2/stable-security,now 2.9.10+dfsg-6.7+deb11u3 amd64 [installed,automatic]
libxmlsec1-dev/stable,now 1.2.31-1 amd64 [installed]
libxmlsec1-gcrypt/stable,now 1.2.31-1 amd64 [installed,automatic]
libxmlsec1-gnutls/stable,now 1.2.31-1 amd64 [installed,automatic]
libxmlsec1-nss/stable,now 1.2.31-1 amd64 [installed,automatic]
libxmlsec1-openssl/stable,now 1.2.31-1 amd64 [installed]
libxmlsec1/stable,now 1.2.31-1 amd64 [installed]
openssl/stable,stable-security,now 1.1.1n-0+deb11u3 amd64 [installed,automatic]

As per the title of this issue, I'm running into problems if using read_dcp against a DCP which contains a sound reel:

$ /usr/local/src/libdcp/build/examples/read_dcp 
Segmentation fault (core dumped)

The core file is attached; I needed to add a .txt extension to overcome GitHubs limitation regarding which files they allow to be uploaded. strace shows what seems to be a problem while seeking into the audio reel. The relevant log is attached as well. Also, the bt of gdb is attached. There is also a screenshot attached of the gdb output with colors included.

core-read_dcp.51288.dev.1670857179.txt strace.log gdb.log gdb

One problem seems to be:

Thread 1 (Thread 0x7fe53b1ebe80 (LWP 51288)):
#0  0x00007fe53e77e899 in ASDCP::Dictionary::Type(ASDCP::MDD_t) const (this=0x0, type_id=ASDCP::MDD_SoundfieldGroupLabelSubDescriptor) at ../src/Dict.cpp:245
        __PRETTY_FUNCTION__ = "const ASDCP::MDDEntry& ASDCP::Dictionary::Type(ASDCP::MDD_t) const"
        rii = non-dereferenceable iterator for associative container

Again, as per the title of this issue, read_dcp works with a DCP which doesn't include a sound reel:

$ /usr/local/src/libdcp/build/examples/read_dcp 
DCP is not encrypted.
DCP has 1 CPLs.
DCP has 2 assets.
CPL
    cpl_c966c3f9-0466-408f-8cbb-f1047fed2a75.xml
2D picture
    j2c_03b04c59-3f09-465c-815e-98a57b6ac3d3.mxf

In contrast, dcpinfo is able to handle both DCPs:

$ dcpinfo /usr/local/share/SilentDCP_SHR_S-239_XX-XX_INT_00_2K_IFB_20221209_IFB_SMPTE_OV/
DCP: /usr/local/share/SilentDCP_SHR_S-239_XX-XX_INT_00_2K_IFB_20221209_IFB_SMPTE_OV/
  CPL: SilentDCP_SHR_S-239_XX-XX_INT_00_2K_IFB_20221209_IFB_SMPTE_OV c0283c7e-0778-491c-9ce9-94802f095804
    Reel 1
      Picture ID:  a5803429-7824-4780-8652-c8dd833b1be4 entry 0 duration 1906 (00:01:19:10) intrinsic 1906
      Picture:     2048x858
      Sound ID:    57d97d51-0bb1-4756-b413-8e9140602ccc entry 0 duration 1906 intrinsic 1906
      Sound:       6 channels at 48000Hz
Total: 00:01:19:10
$ dcpinfo /usr/local/share/DCPWithoutSoundReel_SHR_S-239_XX-XX_INT_00_2K_IFB_20221209_IFB_SMPTE_OV/
DCP: /usr/local/share/DCPWithoutSoundReel_SHR_S-239_XX-XX_INT_00_2K_IFB_20221209_IFB_SMPTE_OV/
  CPL: MBMV_SHR-1-25_S_FR-XX_51_2K_20221004_SMPTE_OV c966c3f9-0466-408f-8cbb-f1047fed2a75
    Reel 1
      Picture ID:  03b04c59-3f09-465c-815e-98a57b6ac3d3 entry 0 duration 15083 (00:10:03:08) intrinsic 15083
      Picture:     2048x858
Total: 00:10:03:08

In case that's helpful, I'm able to provide both DCPs, and also whatever else might be helpful in debugging this.

Any ideas, pointers, things I could try?

Thanks again & all the best!

cth103 commented 1 year ago

Thanks for the comprehensive report! This should be fixed by fe474571eda2ef0eed219d32a9e517512faec52a Let me know if you still have problems after that!

geor-g commented 1 year ago

Thanks so much -- works as expected now!