Crash in x265::Encoder::printSummary () with LOG_CU_STATISTICS

Issue #43 resolved
Peter Kovář created an issue

There is a crash after encode ends during access to enclog.totalCu at line 537 in the source/encoder/encoder.cpp

Comments (12)

  1. Steve Borho

    I can't reproduce a crash. I tried a default encode and one with no B and one with no P or B.

    What version were you running, and what command line arguments were used?

  2. Peter Kovář reporter

    hg tip changeset: 6512:ba3ddc1848ff tag: tip user: Steve Borho steve@borho.org date: Fri Mar 14 12:56:01 2014 -0500 summary: TEncSearch: mvpIdx shares storage with mergeIdx, do not set for merge CUs

    ffmpeg_g -y -r 50 -start_number 12987 -i /Video/SGI/vqeg.its.bldrdoc.gov/HDTV/SVT_MultiFormat/2160p50_CgrLevels_Master_SVTdec05_/3_DucksTakeOff_2160p50_CgrLevels_MASTER_SVTdec05_/%05d.sgi -c:v libx265 -x265-params me=2:b-adapt=2:bframes=4:bitrate=4000 -s 1280x720 ~/Video/HEVC/3_DucksTakeOff_720p50_CgrLevels_MASTER_SVTdec05.hevc

    (gdb) bt #0 x265::Encoder::printSummary (this=this@entry=0x69abf0) at /home/peter.kovar/x265/source/encoder/encoder.cpp:537 #1 0x00007ffff359a9ce in x265_encoder_close (enc=0x69abf0) at /home/peter.kovar/x265/source/encoder/api.cpp:152 #2 0x00007ffff64f8369 in ?? () from /lib64/libavcodec.so.55 #3 0x00007ffff650dd4a in avcodec_close () from /lib64/libavcodec.so.55 #4 0x0000000000407755 in transcode () at /usr/src/FFmpeg/ffmpeg.c:3483 #5 main (argc=<optimized out>, argv=<optimized out>) at /usr/src/FFmpeg/ffmpeg.c:3622 (gdb) frame 0 #0 x265::Encoder::printSummary (this=this@entry=0x69abf0) at /home/peter.kovar/x265/source/encoder/encoder.cpp:537 (gdb) print depth $1 = 0 (gdb) print row $2 = 0 (gdb) print j $3 = <optimized out> (gdb)

  3. Peter Kovář reporter

    I've added som debug code and repeated the crash:

    x265 [info]: depth = 0 j = 1 m_frameEncoder[0].m_numRows = 12 x265 [info]: depth = 0 j = 1 row = 0

    Program received signal SIGSEGV, Segmentation fault. x265::Encoder::printSummary (this=this@entry=0x69abf0) at /usr/src/Video/x265/source/encoder/encoder.cpp:527

  4. Steve Borho

    What does the console output look like prior to the crash? it almost appears to me that the encoder is being closed twice.

  5. Peter Kovář reporter

    I've added output to log in x265_encoder_close, which is called only once. The crash is by j equal to 1.

    Output #0, hevc, to '/home/peter.kovar/Video/HEVC/3_DucksTakeOff_720p50_CgrLevels_MASTER_SVTdec05.hevc': Metadata: encoder : Lavf55.34.101 Stream #0:0: Video: hevc (libx265), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 50 tbc Stream mapping: Stream #0:0 -> #0:0 (sgi -> libx265) Press [q] to stop, [?] for help frame= 500 fps=0.8 q=0.0 Lsize= 4891kB time=00:00:09.96 bitrate=4023.0kbits/s
    video:4891kB audio:0kB subtitle:0 data:0 global headers:0kB muxing overhead 0.000000% x265 [info]: x265_encoder_close (0x69aa30) x265 [info]: depth = 0 j = 0 m_frameEncoder[0].m_numRows = 12 x265 [info]: depth = 0 j = 0 row = 0 x265 [info]: depth = 0 j = 0 row = 1 x265 [info]: depth = 0 j = 0 row = 2 x265 [info]: depth = 0 j = 0 row = 3 x265 [info]: depth = 0 j = 0 row = 4 x265 [info]: depth = 0 j = 0 row = 5 x265 [info]: depth = 0 j = 0 row = 6 x265 [info]: depth = 0 j = 0 row = 7 x265 [info]: depth = 0 j = 0 row = 8 x265 [info]: depth = 0 j = 0 row = 9 x265 [info]: depth = 0 j = 0 row = 10 x265 [info]: depth = 0 j = 0 row = 11 x265 [info]: depth = 0 j = 1 m_frameEncoder[0].m_numRows = 12 x265 [info]: depth = 0 j = 1 row = 0

    Program received signal SIGSEGV, Segmentation fault. x265::Encoder::printSummary (this=this@entry=0x69aa30) at /usr/src/Video/x265/source/encoder/encoder.cpp:527

  6. Steve Borho

    I'm at a loss to explain that. If m_frameEncoder[1] was an invalid pointer, it should have crashes long before dumping stats at the end of the encode.

    Hmm. In a recent refactor, the encoder no longer keeps an internal copy of the param structure and instead keeps a pointer to the param that was passed to x265_encoder_open(). Perhaps ffmpeg is releasing the param prior to closing the encoder?

    I think I'll put the copy back just because this is even possible

  7. Peter Kovář reporter

    frame= 500 fps=0.8 q=0.0 Lsize= 4891kB time=00:00:09.96 bitrate=4023.0kbits/s
    video:4891kB audio:0kB subtitle:0 data:0 global headers:0kB muxing overhead 0.000000% x265 [info]: x265_encoder_close (0x69aa30) x265 [info]: depth = 0 j = 0 m_frameEncoder[j].m_numRows = 12 x265 [info]: depth = 0 j = 0 row = 0 x265 [info]: depth = 0 j = 0 row = 1 x265 [info]: depth = 0 j = 0 row = 2 x265 [info]: depth = 0 j = 0 row = 3 x265 [info]: depth = 0 j = 0 row = 4 x265 [info]: depth = 0 j = 0 row = 5 x265 [info]: depth = 0 j = 0 row = 6 x265 [info]: depth = 0 j = 0 row = 7 x265 [info]: depth = 0 j = 0 row = 8 x265 [info]: depth = 0 j = 0 row = 9 x265 [info]: depth = 0 j = 0 row = 10 x265 [info]: depth = 0 j = 0 row = 11 x265 [info]: depth = 0 j = 1 m_frameEncoder[j].m_numRows = 0 x265 [info]: depth = 0 j = 2 m_frameEncoder[j].m_numRows = 0 x265 [info]: depth = 0 j = 3 m_frameEncoder[j].m_numRows = 0 x265 [info]: depth = 0 j = 4 m_frameEncoder[j].m_numRows = 0 x265 [info]: depth = 0 j = 5 m_frameEncoder[j].m_numRows = 0 x265 [info]: depth = 0 j = 6 m_frameEncoder[j].m_numRows = 0 x265 [info]: depth = 0 j = 7 m_frameEncoder[j].m_numRows = 1704224 x265 [info]: depth = 0 j = 7 row = 0

    Program received signal SIGSEGV, Segmentation fault. x265::Encoder::printSummary (this=this@entry=0x69aa30) at /usr/src/Video/x265/source/encoder/encoder.cpp:527 Missing separate debuginfos, use: debuginfo-install systemd-libs-208-11.fc21.x86_64 (gdb) print m_frameEncoder[j].m_rows[row] Cannot access memory at address 0x14001a001e0001 (gdb)

  8. Steve Borho

    encoder: keep copy of input parameters (refs #43)

    We do not want to allow the user to change the param used by the encoder during the encode, nor do we want to suffer from cleanup ordering issues. We can't crash if the user released the param struct they allocated prior to closing the encoder

    → <<cset 56a382eb1b72>>

  9. Log in to comment