Mixing two audio inputs together as fast as possible ffmpeg - audio

Currently trying to mix two audio streams together to perform an overlay. (Vocals over Instruments). I have two M4A files and I want to combine them together. If the vocal track is 30 seconds, it takes roughly 32 seconds to mix them together, but was hoping for significantly faster processing.
Here is the code I'm using
-ss 0.300 -i /data/user/0/me.rapchat.rapchat/cache/recording.m4a -i /data/user/0/me.rapchat.rapchat/cache/beats/cc3613da-849b-47a5-97b1-b9bf3f1136db.m4a -filter_complex [0:a][1:a]amerge=inputs=2,pan=stereo|c0<c0+c2|c1<c1+c3[aout] -map [aout] /data/user/0/me.rapchat.rapchat/cache/rap.m4a
I've read about using the preset Ultrafast but not sure how it would fit in as I've tried adding it and gotten errors about it's placement in the command. I've also read about copying the stream "as is" and not worrying about encoding/decoding which I was curious if that would speed up the whole process.
And here are my logs for a succesful mix
09-23 15:08:08.412 13909-13909/me.rapchat.rapchat E/Studio Process: ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
09-23 15:08:08.412 13909-13909/me.rapchat.rapchat E/Studio Process: built with gcc 4.8 (GCC)
09-23 15:08:08.412 13909-13909/me.rapchat.rapchat E/Studio Process: configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
09-23 15:08:08.412 13909-13909/me.rapchat.rapchat E/Studio Process: libavutil 55. 17.103 / 55. 17.103
09-23 15:08:08.412 13909-13909/me.rapchat.rapchat E/Studio Process: libavcodec 57. 24.102 / 57. 24.102
09-23 15:08:08.412 13909-13909/me.rapchat.rapchat E/Studio Process: libavformat 57. 25.100 / 57. 25.100
09-23 15:08:08.412 13909-13909/me.rapchat.rapchat E/Studio Process: libavdevice 57. 0.101 / 57. 0.101
09-23 15:08:08.412 13909-13909/me.rapchat.rapchat E/Studio Process: libavfilter 6. 31.100 / 6. 31.100
09-23 15:08:08.412 13909-13909/me.rapchat.rapchat E/Studio Process: libswscale 4. 0.100 / 4. 0.100
09-23 15:08:08.412 13909-13909/me.rapchat.rapchat E/Studio Process: libswresample 2. 0.101 / 2. 0.101
09-23 15:08:08.412 13909-13909/me.rapchat.rapchat E/Studio Process: libpostproc 54. 0.100 / 54. 0.100
09-23 15:08:08.442 13909-13909/me.rapchat.rapchat E/Studio Process: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/user/0/me.rapchat.rapchat/cache/recording.m4a':
09-23 15:08:08.442 13909-13909/me.rapchat.rapchat E/Studio Process: Metadata:
09-23 15:08:08.442 13909-13909/me.rapchat.rapchat E/Studio Process: major_brand : mp42
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: minor_version : 0
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: compatible_brands: isommp42
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: creation_time : 2016-09-23 20:08:08
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: com.android.version: 6.0.1
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: Duration: 00:00:34.74, start: 0.000000, bitrate: 64 kb/s
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: Stream #0:0(eng): Audio: aac (HE-AAC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 64 kb/s (default)
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: Metadata:
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: creation_time : 2016-09-23 20:08:08
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: handler_name : SoundHandle
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/data/user/0/me.rapchat.rapchat/cache/beats/cc3613da-849b-47a5-97b1-b9bf3f1136db.m4a':
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: Metadata:
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: major_brand : M4A
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: minor_version : 0
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: compatible_brands: M4A mp42isom
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: creation_time : 2016-06-21 20:00:19
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: artist :
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: album : Rapchat
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: date : 2016
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: composer :
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: title : wrist - beat
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: encoder : 10.2.0
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: iTunSMPB : 00000000 00000840 000003BF 00000000004A0001 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: Duration: 00:01:50.04, start: 0.000000, bitrate: 110 kb/s
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: Stream #1:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 259 kb/s (default)
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: Metadata:
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: creation_time : 2016-06-21 20:00:19
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: [Parsed_amerge_0 # 0xf6f57140] No channel layout for input 1
09-23 15:08:08.452 13909-13909/me.rapchat.rapchat E/Studio Process: [Parsed_amerge_0 # 0xf6f57140] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
09-23 15:08:08.472 13909-13909/me.rapchat.rapchat E/Studio Process: Output #0, ipod, to '/data/user/0/me.rapchat.rapchat/cache/rap.m4a':
09-23 15:08:08.472 13909-13909/me.rapchat.rapchat E/Studio Process: Metadata:
09-23 15:08:08.482 13909-13909/me.rapchat.rapchat E/Studio Process: major_brand : mp42
09-23 15:08:08.482 13909-13909/me.rapchat.rapchat E/Studio Process: minor_version : 0
09-23 15:08:08.482 13909-13909/me.rapchat.rapchat E/Studio Process: compatible_brands: isommp42
09-23 15:08:08.482 13909-13909/me.rapchat.rapchat E/Studio Process: com.android.version: 6.0.1
09-23 15:08:08.482 13909-13909/me.rapchat.rapchat E/Studio Process: encoder : Lavf57.25.100
09-23 15:08:08.482 13909-13909/me.rapchat.rapchat E/Studio Process: Stream #0:0: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
09-23 15:08:08.482 13909-13909/me.rapchat.rapchat E/Studio Process: Metadata:
09-23 15:08:08.482 13909-13909/me.rapchat.rapchat E/Studio Process: encoder : Lavc57.24.102 aac
09-23 15:08:08.482 13909-13909/me.rapchat.rapchat E/Studio Process: Stream mapping:
09-23 15:08:08.482 13909-13909/me.rapchat.rapchat E/Studio Process: Stream #0:0 (aac) -> amerge:in0
09-23 15:08:08.482 13909-13909/me.rapchat.rapchat E/Studio Process: Stream #1:0 (aac) -> amerge:in1
09-23 15:08:08.482 13909-13909/me.rapchat.rapchat E/Studio Process: pan -> Stream #0:0 (aac)
09-23 15:08:08.482 13909-13909/me.rapchat.rapchat E/Studio Process: Press [q] to stop, [?] for help
09-23 15:08:09.022 13909-13909/me.rapchat.rapchat E/Studio Process: size= 9kB time=00:00:00.62 bitrate= 115.8kbits/s speed=1.22x
09-23 15:08:09.532 13909-13909/me.rapchat.rapchat E/Studio Process: size= 21kB time=00:00:01.41 bitrate= 122.7kbits/s speed=1.39x
09-23 15:08:10.032 13909-13909/me.rapchat.rapchat E/Studio Process: size= 34kB time=00:00:02.20 bitrate= 124.6kbits/s speed=1.45x
09-23 15:08:10.532 13909-13909/me.rapchat.rapchat E/Studio Process: size= 47kB time=00:00:03.04 bitrate= 125.6kbits/s speed= 1.5x
09-23 15:08:11.052 13909-13909/me.rapchat.rapchat E/Studio Process: size= 59kB time=00:00:03.83 bitrate= 126.1kbits/s speed=1.51x
09-23 15:08:11.552 13909-13909/me.rapchat.rapchat E/Studio Process: size= 71kB time=00:00:04.62 bitrate= 126.4kbits/s speed=1.51x
09-23 15:08:12.062 13909-13909/me.rapchat.rapchat E/Studio Process: size= 84kB time=00:00:05.41 bitrate= 126.6kbits/s speed=1.52x
09-23 15:08:12.582 13909-13909/me.rapchat.rapchat E/Studio Process: size= 97kB time=00:00:06.24 bitrate= 126.8kbits/s speed=1.53x
09-23 15:08:13.072 13909-13909/me.rapchat.rapchat E/Studio Process: size= 109kB time=00:00:07.03 bitrate= 126.9kbits/s speed=1.54x
09-23 15:08:13.572 13909-13909/me.rapchat.rapchat E/Studio Process: size= 121kB time=00:00:07.82 bitrate= 127.1kbits/s speed=1.54x
09-23 15:08:14.092 13909-13909/me.rapchat.rapchat E/Studio Process: size= 134kB time=00:00:08.61 bitrate= 127.1kbits/s speed=1.54x
09-23 15:08:14.602 13909-13909/me.rapchat.rapchat E/Studio Process: size= 146kB time=00:00:09.40 bitrate= 127.2kbits/s speed=1.54x
09-23 15:08:15.122 13909-13909/me.rapchat.rapchat E/Studio Process: size= 159kB time=00:00:10.24 bitrate= 127.3kbits/s speed=1.55x
09-23 15:08:15.592 13909-13909/me.rapchat.rapchat E/Studio Process: size= 171kB time=00:00:10.98 bitrate= 127.3kbits/s speed=1.55x
09-23 15:08:16.112 13909-13909/me.rapchat.rapchat E/Studio Process: size= 183kB time=00:00:11.77 bitrate= 127.4kbits/s speed=1.55x
09-23 15:08:16.612 13909-13909/me.rapchat.rapchat E/Studio Process: size= 195kB time=00:00:12.56 bitrate= 127.4kbits/s speed=1.55x
09-23 15:08:17.122 13909-13909/me.rapchat.rapchat E/Studio Process: size= 208kB time=00:00:13.39 bitrate= 127.4kbits/s speed=1.55x
09-23 15:08:17.692 13909-13909/me.rapchat.rapchat E/Studio Process: size= 217kB time=00:00:13.90 bitrate= 127.9kbits/s speed=1.52x
09-23 15:08:18.162 13909-13909/me.rapchat.rapchat E/Studio Process: size= 223kB time=00:00:14.28 bitrate= 127.8kbits/s speed=1.48x
09-23 15:08:18.662 13909-13909/me.rapchat.rapchat E/Studio Process: size= 229kB time=00:00:14.65 bitrate= 127.8kbits/s speed=1.44x
09-23 15:08:19.202 13909-13909/me.rapchat.rapchat E/Studio Process: size= 235kB time=00:00:15.06 bitrate= 127.7kbits/s speed=1.41x
09-23 15:08:19.792 13909-13909/me.rapchat.rapchat E/Studio Process: size= 240kB time=00:00:15.39 bitrate= 127.8kbits/s speed=1.38x
09-23 15:08:20.192 13909-13909/me.rapchat.rapchat E/Studio Process: size= 244kB time=00:00:15.67 bitrate= 127.8kbits/s speed=1.34x
09-23 15:08:20.712 13909-13909/me.rapchat.rapchat E/Studio Process: size= 252kB time=00:00:16.13 bitrate= 127.7kbits/s speed=1.32x
09-23 15:08:21.242 13909-13909/me.rapchat.rapchat E/Studio Process: size= 257kB time=00:00:16.46 bitrate= 127.8kbits/s speed=1.29x
09-23 15:08:21.752 13909-13909/me.rapchat.rapchat E/Studio Process: size= 260kB time=00:00:16.64 bitrate= 127.8kbits/s speed=1.25x
09-23 15:08:22.272 13909-13909/me.rapchat.rapchat E/Studio Process: size= 264kB time=00:00:16.92 bitrate= 127.7kbits/s speed=1.23x
09-23 15:08:22.882 13909-13909/me.rapchat.rapchat E/Studio Process: size= 269kB time=00:00:17.29 bitrate= 127.6kbits/s speed=1.21x
09-23 15:08:23.352 13909-13909/me.rapchat.rapchat E/Studio Process: size= 274kB time=00:00:17.62 bitrate= 127.5kbits/s speed=1.19x
09-23 15:08:23.952 13909-13909/me.rapchat.rapchat E/Studio Process: size= 282kB time=00:00:18.13 bitrate= 127.6kbits/s speed=1.18x
09-23 15:08:24.372 13909-13909/me.rapchat.rapchat E/Studio Process: size= 285kB time=00:00:18.32 bitrate= 127.6kbits/s speed=1.15x
09-23 15:08:24.892 13909-13909/me.rapchat.rapchat E/Studio Process: size= 290kB time=00:00:18.59 bitrate= 127.6kbits/s speed=1.13x
09-23 15:08:25.402 13909-13909/me.rapchat.rapchat E/Studio Process: size= 293kB time=00:00:18.85 bitrate= 127.5kbits/s speed=1.12x
09-23 15:08:26.032 13909-13909/me.rapchat.rapchat E/Studio Process: size= 300kB time=00:00:19.24 bitrate= 127.5kbits/s speed= 1.1x
09-23 15:08:26.462 13909-13909/me.rapchat.rapchat E/Studio Process: size= 304kB time=00:00:19.57 bitrate= 127.4kbits/s speed=1.09x
09-23 15:08:27.042 13909-13909/me.rapchat.rapchat E/Studio Process: size= 309kB time=00:00:19.89 bitrate= 127.4kbits/s speed=1.07x
09-23 15:08:27.622 13909-13909/me.rapchat.rapchat E/Studio Process: size= 312kB time=00:00:20.08 bitrate= 127.4kbits/s speed=1.05x
09-23 15:08:28.182 13909-13909/me.rapchat.rapchat E/Studio Process: size= 317kB time=00:00:20.36 bitrate= 127.4kbits/s speed=1.03x
09-23 15:08:28.702 13909-13909/me.rapchat.rapchat E/Studio Process: size= 322kB time=00:00:20.68 bitrate= 127.3kbits/s speed=1.02x
09-23 15:08:29.262 13909-13909/me.rapchat.rapchat E/Studio Process: size= 326kB time=00:00:20.96 bitrate= 127.3kbits/s speed=1.01x
09-23 15:08:29.762 13909-13909/me.rapchat.rapchat E/Studio Process: size= 332kB time=00:00:21.38 bitrate= 127.3kbits/s speed=1.01x
09-23 15:08:30.282 13909-13909/me.rapchat.rapchat E/Studio Process: size= 339kB time=00:00:21.80 bitrate= 127.3kbits/s speed= 1x
09-23 15:08:30.892 13909-13909/me.rapchat.rapchat E/Studio Process: size= 345kB time=00:00:22.22 bitrate= 127.3kbits/s speed=0.995x
09-23 15:08:31.392 13909-13909/me.rapchat.rapchat E/Studio Process: size= 352kB time=00:00:22.63 bitrate= 127.3kbits/s speed=0.989x
09-23 15:08:31.942 13909-13909/me.rapchat.rapchat E/Studio Process: size= 359kB time=00:00:23.10 bitrate= 127.3kbits/s speed=0.986x
09-23 15:08:32.452 13909-13909/me.rapchat.rapchat E/Studio Process: size= 363kB time=00:00:23.38 bitrate= 127.3kbits/s speed=0.977x
09-23 15:08:32.932 13909-13909/me.rapchat.rapchat E/Studio Process: size= 367kB time=00:00:23.61 bitrate= 127.4kbits/s speed=0.966x
09-23 15:08:33.542 13909-13909/me.rapchat.rapchat E/Studio Process: size= 372kB time=00:00:23.93 bitrate= 127.3kbits/s speed=0.96x
09-23 15:08:33.942 13909-13909/me.rapchat.rapchat E/Studio Process: size= 378kB time=00:00:24.31 bitrate= 127.3kbits/s speed=0.955x
09-23 15:08:34.462 13909-13909/me.rapchat.rapchat E/Studio Process: size= 384kB time=00:00:24.68 bitrate= 127.3kbits/s speed=0.951x
09-23 15:08:35.022 13909-13909/me.rapchat.rapchat E/Studio Process: size= 389kB time=00:00:25.05 bitrate= 127.3kbits/s speed=0.945x
09-23 15:08:35.542 13909-13909/me.rapchat.rapchat E/Studio Process: size= 392kB time=00:00:25.24 bitrate= 127.3kbits/s speed=0.933x
09-23 15:08:36.082 13909-13909/me.rapchat.rapchat E/Studio Process: size= 399kB time=00:00:25.65 bitrate= 127.3kbits/s speed=0.931x
09-23 15:08:36.572 13909-13909/me.rapchat.rapchat E/Studio Process: size= 405kB time=00:00:26.07 bitrate= 127.3kbits/s speed=0.929x
09-23 15:08:37.082 13909-13909/me.rapchat.rapchat E/Studio Process: size= 410kB time=00:00:26.40 bitrate= 127.3kbits/s speed=0.924x
09-23 15:08:37.632 13909-13909/me.rapchat.rapchat E/Studio Process: size= 417kB time=00:00:26.81 bitrate= 127.3kbits/s speed=0.921x
09-23 15:08:37.862 13909-16848/me.rapchat.rapchat I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
09-23 15:08:37.862 13909-16848/me.rapchat.rapchat I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
09-23 15:08:38.172 13909-13909/me.rapchat.rapchat E/Studio Process: size= 422kB time=00:00:27.14 bitrate= 127.3kbits/s speed=0.915x
09-23 15:08:38.672 13909-13909/me.rapchat.rapchat E/Studio Process: size= 427kB time=00:00:27.51 bitrate= 127.3kbits/s speed=0.912x
09-23 15:08:39.182 13909-13909/me.rapchat.rapchat E/Studio Process: size= 432kB time=00:00:27.79 bitrate= 127.4kbits/s speed=0.906x
09-23 15:08:39.692 13909-13909/me.rapchat.rapchat E/Studio Process: size= 440kB time=00:00:28.25 bitrate= 127.5kbits/s speed=0.906x
09-23 15:08:40.202 13909-13909/me.rapchat.rapchat E/Studio Process: size= 449kB time=00:00:28.81 bitrate= 127.6kbits/s speed=0.909x
09-23 15:08:40.702 13909-13909/me.rapchat.rapchat E/Studio Process: size= 456kB time=00:00:29.28 bitrate= 127.7kbits/s speed=0.909x
09-23 15:08:41.222 13909-13909/me.rapchat.rapchat E/Studio Process: size= 463kB time=00:00:29.69 bitrate= 127.8kbits/s speed=0.908x
09-23 15:08:41.782 13909-13909/me.rapchat.rapchat E/Studio Process: size= 471kB time=00:00:30.16 bitrate= 127.9kbits/s speed=0.907x
09-23 15:08:42.282 13909-13909/me.rapchat.rapchat E/Studio Process: size= 477kB time=00:00:30.53 bitrate= 128.0kbits/s speed=0.905x
09-23 15:08:42.782 13909-13909/me.rapchat.rapchat E/Studio Process: size= 485kB time=00:00:31.04 bitrate= 128.1kbits/s speed=0.906x
09-23 15:08:43.292 13909-13909/me.rapchat.rapchat E/Studio Process: size= 494kB time=00:00:31.55 bitrate= 128.2kbits/s speed=0.907x
09-23 15:08:43.872 13909-13909/me.rapchat.rapchat E/Studio Process: size= 501kB time=00:00:31.97 bitrate= 128.4kbits/s speed=0.905x
09-23 15:08:44.472 13909-13909/me.rapchat.rapchat E/Studio Process: size= 510kB time=00:00:32.48 bitrate= 128.5kbits/s speed=0.906x
09-23 15:08:44.872 13909-13909/me.rapchat.rapchat E/Studio Process: size= 516kB time=00:00:32.85 bitrate= 128.6kbits/s speed=0.904x
09-23 15:08:45.442 13909-13909/me.rapchat.rapchat E/Studio Process: size= 524kB time=00:00:33.36 bitrate= 128.7kbits/s speed=0.903x
09-23 15:08:46.012 13909-13909/me.rapchat.rapchat E/Studio Process: size= 529kB time=00:00:33.69 bitrate= 128.7kbits/s speed=0.898x
09-23 15:08:46.512 13909-13909/me.rapchat.rapchat E/Studio Process: size= 532kB time=00:00:33.87 bitrate= 128.7kbits/s speed=0.891x
09-23 15:08:47.072 13909-13909/me.rapchat.rapchat E/Studio Process: size= 536kB time=00:00:34.11 bitrate= 128.7kbits/s speed=0.885x
09-23 15:08:47.572 13909-13909/me.rapchat.rapchat E/Studio Process: size= 540kB time=00:00:34.38 bitrate= 128.7kbits/s speed=0.88x
09-23 15:08:47.722 13909-13909/me.rapchat.rapchat E/Studio Process: size= 547kB time=00:00:34.45 bitrate= 130.2kbits/s speed=0.878x
09-23 15:08:47.722 13909-13909/me.rapchat.rapchat E/Studio Process: video:0kB audio:541kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.207577%
09-23 15:08:47.722 13909-13909/me.rapchat.rapchat E/Studio Process: [aac # 0xf6f43400] Qavg: 12320.994
The problem is that there is some time delay on this and i'm not sure how to go about optimizing this. I'm pretty new to FFMPEG and the syntax has quite the learning curve when throwing in presets, and codecs. Will the preset ultrafast be what i'm looking for, and how do I add it to this?
Thank you in advance!

Related

Raspberry Pi Youtube Livestream - ffmpeg error: av_interleaved_write_frame(): Broken pipe

I'm using a Raspberry Pi 3B (OS: Raspian) to livestream an attached camera feed to YouTube using the following command in a python script(I removed the livestream secret key):
raspivid -o - -t 0 -vf -hf -fps 30 -b 6000000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -thread_queue_size 1024 -i /dev/zero -f h264 -thread_queue_size 1024 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/[My Secret Key]> /home/Desktop/Livestream_Logs/Output_Runthrough.txt 2>&1
However, I am running into a problem where the livestream cuts out at random times (usually after an hour) and the command terminates due to the following error: av_interleaved_write_frame(): Broken pipe
I am new to the ffmpeg command and live-streaming in general, so please go easy on me for I do not know what I am doing wrong with this command, nor do I understand all its arguments! This is a Christmas project I am working on, and I copied this command from this site.
Below is the output log from running the command. There were over 60,000 frames in the log so I removed most lines to save space, but included some samples; the bitrate and speed remained relatively the same throughout the command's execution:
ffmpeg version 4.3.5-0+deb11u1+rpt2 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 10 (Raspbian 10.2.1-6+rpi1)
configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --libdir=/usr/lib/arm-linux-gnueabihf --cpu=arm1176jzf-s --arch=arm
WARNING: library configuration mismatch
avutil configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
avcodec configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
avformat configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
avdevice configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
avfilter configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
avresample configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
swscale configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
swresample configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
postproc configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, s16le, from '/dev/zero':
Duration: N/A, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Input #1, h264, from 'pipe:':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Stream mapping:
Stream #1:0 -> #0:0 (copy)
Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Output #0, flv, to 'rtmp://a.rtmp.youtube.com/live2/[My Secret Key]':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (High) ([7][0][0][0] / 0x0007), yuv420p(progressive), 1920x1080, q=2-31, 25 fps, 25 tbr, 1k tbn, 1200k tbc
Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.91.100 aac
[flv # 0x17f25a0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
frame= 13 fps=0.0 q=-1.0 size= 196kB time=00:00:00.48 bitrate=3338.1kbits/s speed=0.945x
frame= 25 fps= 25 q=-1.0 size= 598kB time=00:00:00.97 bitrate=5021.1kbits/s speed=0.958x
frame= 38 fps= 25 q=-1.0 size= 911kB time=00:00:01.48 bitrate=5023.5kbits/s speed=0.977x
frame= 51 fps= 25 q=-1.0 size= 1236kB time=00:00:02.00 bitrate=5060.4kbits/s speed=0.987x
frame= 63 fps= 25 q=-1.0 size= 1622kB time=00:00:02.50 bitrate=5299.4kbits/s speed=0.989x
frame= 76 fps= 25 q=-1.0 size= 1866kB time=00:00:03.00 bitrate=5093.2kbits/s speed=0.988x
frame= 89 fps= 25 q=-1.0 size= 2157kB time=00:00:03.52 bitrate=5017.7kbits/s speed=0.992x
frame= 101 fps= 25 q=-1.0 size= 2435kB time=00:00:04.01 bitrate=4965.0kbits/s speed=0.992x
frame= 2119 fps= 25 q=-1.0 size= 51856kB time=00:01:24.72 bitrate=5013.7kbits/s speed= 1x
frame= 2131 fps= 25 q=-1.0 size= 52156kB time=00:01:25.24 bitrate=5012.4kbits/s speed= 1x
frame= 2144 fps= 25 q=-1.0 size= 52465kB time=00:01:25.75 bitrate=5012.0kbits/s speed= 1x
frame= 2157 fps= 25 q=-1.0 size= 52757kB time=00:01:26.24 bitrate=5011.4kbits/s speed= 1x
frame= 2170 fps= 25 q=-1.0 size= 53104kB time=00:01:26.76 bitrate=5014.1kbits/s speed= 1x
frame= 2182 fps= 25 q=-1.0 size= 53390kB time=00:01:27.26 bitrate=5012.2kbits/s speed= 1x
frame= 2195 fps= 25 q=-1.0 size= 53711kB time=00:01:27.77 bitrate=5013.0kbits/s speed= 1x
frame= 2207 fps= 25 q=-1.0 size= 53997kB time=00:01:28.25 bitrate=5011.9kbits/s speed=0.999x
frame= 2220 fps= 25 q=-1.0 size= 54299kB time=00:01:28.77 bitrate=5010.9kbits/s speed= 1x
frame= 2232 fps= 25 q=-1.0 size= 54641kB time=00:01:29.28 bitrate=5013.6kbits/s speed= 1x
frame= 2245 fps= 25 q=-1.0 size= 54952kB time=00:01:29.79 bitrate=5013.5kbits/s speed= 1x
frame= 6384 fps= 25 q=-1.0 size= 156217kB time=00:04:15.32 bitrate=5012.1kbits/s speed= 1x
frame=63216 fps= 25 q=-1.0 size= 1547043kB time=00:42:08.63 bitrate=5012.0kbits/s speed= 1x
frame=63229 fps= 25 q=-1.0 size= 1547337kB time=00:42:09.12 bitrate=5011.9kbits/s speed= 1x
frame=63242 fps= 25 q=-1.0 size= 1547710kB time=00:42:09.64 bitrate=5012.1kbits/s speed= 1x
frame=63254 fps= 25 q=-1.0 size= 1547959kB time=00:42:10.13 bitrate=5011.9kbits/s speed= 1x
frame=63267 fps= 25 q=-1.0 size= 1548272kB time=00:42:10.65 bitrate=5011.9kbits/s speed= 1x
frame=63274 fps= 25 q=-1.0 size= 1548443kB time=00:42:10.92 bitrate=5011.9kbits/s speed=0.986x
av_interleaved_write_frame(): Broken pipe
[flv # 0x17f25a0] Failed to update header with correct duration.
[flv # 0x17f25a0] Failed to update header with correct filesize.
Error writing trailer of rtmp://a.rtmp.youtube.com/live2/[MY SECRET KEY]: Broken pipe
frame=63274 fps= 25 q=-1.0 Lsize= 1548443kB time=00:42:10.92 bitrate=5011.9kbits/s speed=0.986x
video:1544778kB audio:646kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.195331%
[aac # 0x17ee650] Qavg: 65536.000
Conversion failed!
As stated before the command I am using is from this site. However, they are using avconv instead of ffmpeg, but since avconv would not work on my raspberry pi, I switched out "avconv" for "ffmpeg" and kept all the same flags.
I also added in "-thread_queue_size 1024" before both "-i" flags. This was a solution that I found within this link, which detailed how to get rid of the following error, which I initially thought could be the culprit to my problem but wasn't:
[h264 # 0x1308e30] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)

Youtube Livestream - ffmpeg error: av_interleaved_write_frame(): End of File

I'm using a Raspberry Pi 3B (OS: Raspian) to livestream an attached camera feed to YouTube using the following command in a python script(I removed the livestream secret key):
raspivid -o - -t 0 -vf -hf -fps 30 -b 6000000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -thread_queue_size 1024 -i /dev/zero -f h264 -thread_queue_size 1024 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/[My Secret Key]> /home/Desktop/Livestream_Logs/Output_Runthrough".txt 2>&1
However, I am running into a problem where the livestream cuts out at random times (usually after an hour) and the command terminates due to the following error: av_interleaved_write_frame(): Broken pipe
I am new to the ffmpeg command and live-streaming in general, so please go easy on me for I do not know what I am doing wrong with this command, nor do I understand all its arguments! This is a Christmas project I am working on, and I copied this command from this site.
Below is the output log from running the command. There were over 60,000 frames in the log so I removed most lines to save space, but included some samples; the bitrate and speed remained relatively the same throughout the command's execution:
ffmpeg version 4.3.5-0+deb11u1+rpt2 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 10 (Raspbian 10.2.1-6+rpi1)
configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --libdir=/usr/lib/arm-linux-gnueabihf --cpu=arm1176jzf-s --arch=arm
WARNING: library configuration mismatch
avutil configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
avcodec configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
avformat configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
avdevice configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
avfilter configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
avresample configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
swscale configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
swresample configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
postproc configuration: --prefix=/usr --extra-version=0+deb11u1+rpt2 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, s16le, from '/dev/zero':
Duration: N/A, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Input #1, h264, from 'pipe:':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Stream mapping:
Stream #1:0 -> #0:0 (copy)
Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Output #0, flv, to 'rtmp://a.rtmp.youtube.com/live2/[My Secret Key]':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (High) ([7][0][0][0] / 0x0007), yuv420p(progressive), 1920x1080, q=2-31, 25 fps, 25 tbr, 1k tbn, 1200k tbc
Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.91.100 aac
[flv # 0x130e5f0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[h264 # 0x1308e30] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
frame= 13 fps=0.0 q=-1.0 size= 188kB time=00:00:00.48 bitrate=3202.0kbits/s speed=0.948x
frame= 25 fps= 25 q=-1.0 size= 582kB time=00:00:00.97 bitrate=4892.9kbits/s speed=0.966x
frame= 38 fps= 25 q=-1.0 size= 909kB time=00:00:01.48 bitrate=5012.3kbits/s speed=0.983x
frame= 50 fps= 25 q=-1.0 size= 1219kB time=00:00:01.99 bitrate=5001.6kbits/s speed=0.988x
frame= 63 fps= 25 q=-1.0 size= 1594kB time=00:00:02.48 bitrate=5255.3kbits/s speed=0.983x
frame= 76 fps= 25 q=-1.0 size= 1855kB time=00:00:03.00 bitrate=5064.6kbits/s speed=0.99x
frame= 2144 fps= 25 q=-1.0 size= 52465kB time=00:01:25.75 bitrate=5012.1kbits/s speed= 1x
frame= 2157 fps= 25 q=-1.0 size= 52755kB time=00:01:26.24 bitrate=5011.2kbits/s speed= 1x
frame= 2170 fps= 25 q=-1.0 size= 53101kB time=00:01:26.76 bitrate=5013.8kbits/s speed= 1x
frame=25690 fps= 25 q=-1.0 size= 628697kB time=00:17:07.57 bitrate=5012.1kbits/s speed= 1x
frame=25703 fps= 25 q=-1.0 size= 628980kB time=00:17:08.08 bitrate=5011.8kbits/s speed= 1x
frame=25715 fps= 25 q=-1.0 size= 629295kB time=00:17:08.59 bitrate=5011.9kbits/s speed= 1x
frame=58274 fps= 25 q=-1.0 size= 1426073kB time=00:38:50.93 bitrate=5011.9kbits/s speed= 1x
frame=58287 fps= 25 q=-1.0 size= 1426391kB time=00:38:51.44 bitrate=5011.9kbits/s speed= 1x
frame=58299 fps= 25 q=-1.0 size= 1426707kB time=00:38:51.95 bitrate=5011.9kbits/s speed= 1x
frame=94289 fps= 25 q=-1.0 size= 2307471kB time=01:02:51.54 bitrate=5011.9kbits/s speed= 1x
frame=94302 fps= 25 q=-1.0 size= 2307767kB time=01:02:52.04 bitrate=5011.9kbits/s speed= 1x
frame=94315 fps= 25 q=-1.0 size= 2308071kB time=01:02:52.56 bitrate=5011.9kbits/s speed= 1x
frame=128044 fps= 25 q=-1.0 size= 3133566kB time=01:25:21.74 bitrate=5012.0kbits/s speed= 1x
frame=128057 fps= 25 q=-1.0 size= 3133823kB time=01:25:22.25 bitrate=5011.9kbits/s speed= 1x
frame=128069 fps= 25 q=-1.0 size= 3134109kB time=01:25:22.72 bitrate=5011.9kbits/s speed=0.996x
av_interleaved_write_frame(): End of file
[flv # 0x130e5f0] Failed to update header with correct duration.
[flv # 0x130e5f0] Failed to update header with correct filesize.
Error writing trailer of rtmp://a.rtmp.youtube.com/live2/[My Secret Key]: End of file
frame=128069 fps= 25 q=-1.0 Lsize= 3134109kB time=01:25:22.74 bitrate=5011.9kbits/s speed=0.996x
video:3126661kB audio:1307kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.196311%
[aac # 0x130ed10] Qavg: 65536.000
Conversion failed!
As stated before the command I am using is from this site. However, they are using avconv instead of ffmpeg, but since avconv would not work on my raspberry pi, I switched out "avconv" for "ffmpeg" and kept all the same flags.
Does anyone know why I'm getting this error?

Can't get the reason for a deadlock

I have a mixed application (boost, ACE, cli, C#).
I've loaded dump into WinDbg and here are my investigations:
1) There are 25 threads:
0:024> ~
# 0 Id: 22d8.2e1c Suspend: 0 Teb: 7eb6f000 Unfrozen
1 Id: 22d8.2d90 Suspend: 0 Teb: 7eb6c000 Unfrozen
2 Id: 22d8.2ab0 Suspend: 0 Teb: 7eb65000 Unfrozen
3 Id: 22d8.17c4 Suspend: 0 Teb: 7ea36000 Unfrozen
4 Id: 22d8.1254 Suspend: 0 Teb: 7ea33000 Unfrozen
5 Id: 22d8.227c Suspend: 0 Teb: 7e9cf000 Unfrozen
6 Id: 22d8.f94 Suspend: 0 Teb: 7e9cc000 Unfrozen
7 Id: 22d8.23e8 Suspend: 0 Teb: 7e9c0000 Unfrozen
8 Id: 22d8.19d8 Suspend: 0 Teb: 7e9c6000 Unfrozen
9 Id: 22d8.19fc Suspend: 0 Teb: 7e9bd000 Unfrozen
10 Id: 22d8.1ec8 Suspend: 0 Teb: 7e9ba000 Unfrozen
11 Id: 22d8.149c Suspend: 0 Teb: 7e9b7000 Unfrozen
12 Id: 22d8.1dec Suspend: 0 Teb: 7e9b4000 Unfrozen
13 Id: 22d8.2e50 Suspend: 0 Teb: 7e9b1000 Unfrozen
14 Id: 22d8.19d0 Suspend: 0 Teb: 7e9ae000 Unfrozen
15 Id: 22d8.2f80 Suspend: 0 Teb: 7e9ab000 Unfrozen
16 Id: 22d8.1218 Suspend: 0 Teb: 7e9a8000 Unfrozen
17 Id: 22d8.2874 Suspend: 0 Teb: 7e9a5000 Unfrozen
18 Id: 22d8.1f7c Suspend: 0 Teb: 7e9a2000 Unfrozen
19 Id: 22d8.292c Suspend: 0 Teb: 7e99f000 Unfrozen
20 Id: 22d8.2c6c Suspend: 0 Teb: 7e99c000 Unfrozen
21 Id: 22d8.27ec Suspend: 0 Teb: 7e9c9000 Unfrozen
22 Id: 22d8.ab0 Suspend: 0 Teb: 7ea39000 Unfrozen
23 Id: 22d8.1d54 Suspend: 0 Teb: 7ea3f000 Unfrozen
24 Id: 22d8.2ee8 Suspend: 0 Teb: 7ea3c000 Unfrozen
22 of them are managed threads
0:024> !threads
ThreadCount: 22
UnstartedThread: 1
BackgroundThread: 20
PendingThread: 1
DeadThread: 0
Hosted Runtime: no
Lock
ID OSID ThreadOBJ State GC Mode GC Alloc Context Domain Count Apt Exception
0 1 2e1c 015a8d58 26020 Cooperative 00000000:00000000 015a2f18 1 STA (GC)
2 2 2ab0 015b6b90 2b220 Preemptive 00000000:00000000 015a2f18 0 MTA (Finalizer)
3 3 17c4 016501e0 102a220 Preemptive 00000000:00000000 015a2f18 0 MTA (Threadpool Worker)
5 4 227c 0425f080 1020220 Preemptive 00000000:00000000 015a2f18 0 Ukn (Threadpool Worker)
7 7 23e8 07628058 20220 Preemptive 00000000:00000000 015a2f18 0 Ukn
8 8 19d8 07659a08 20220 Preemptive 00000000:00000000 015a2f18 0 Ukn
9 9 19fc 07667418 20220 Preemptive 00000000:00000000 015a2f18 0 Ukn
10 10 1ec8 07668d18 20220 Preemptive 00000000:00000000 015a2f18 0 Ukn
11 11 149c 0766abc8 20220 Preemptive 00000000:00000000 015a2f18 0 Ukn
12 12 1dec 076724e0 20220 Preemptive 00000000:00000000 015a2f18 0 Ukn
13 13 2e50 07672a28 20220 Preemptive 00000000:00000000 015a2f18 0 Ukn
14 14 19d0 0767a448 20220 Preemptive 00000000:00000000 015a2f18 0 Ukn
15 15 2f80 0767a990 20220 Preemptive 00000000:00000000 015a2f18 0 Ukn
16 16 1218 0767ba88 20220 Preemptive 00000000:00000000 015a2f18 0 Ukn
17 17 2874 076811c0 20220 Preemptive 00000000:00000000 015a2f18 0 Ukn
18 18 1f7c 076826e0 20220 Preemptive 00000000:00000000 015a2f18 0 Ukn
19 19 292c 07683c00 20220 Preemptive 00000000:00000000 015a2f18 0 Ukn
20 20 2c6c 07682198 20220 Preemptive 00000000:00000000 015a2f18 0 Ukn
21 31 27ec 098dfac8 8039220 Preemptive 00000000:00000000 015a2f18 0 Ukn (Threadpool Completion Port)
22 5 ab0 098e0fe8 8029220 Preemptive 00000000:00000000 015a2f18 0 MTA (Threadpool Completion Port)
23 35 1d54 098e0558 1039220 Preemptive 00000000:00000000 015a2f18 0 Ukn (Threadpool Worker)
24 38 2ee8 098df038 1600 Preemptive 00000000:00000000 015a2f18 0 Ukn
3) I've got callstack for these threads (with ~*kvn) and searched for NtWaitForSingleObject:
00 00fae970 74f02cc7 000001c8 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 049ff670 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 07adf63c 7769de07 00000980 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 0817d4f0 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 0858ed00 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 0868ed48 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 087cebf0 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 0890ed00 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 08a4ecd0 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 08c4f600 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 08d8f9a8 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 08ecfab8 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 0900f9c8 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 0914f928 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 0928f890 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 093cf480 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 0950f630 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 0474ebf0 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 07d9ed38 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
00 096cf77c 7769de07 00000980 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
There are 3 events, that are blocking threads:
As far as i understood, the GC thread (which is in cooperative mode) waits untill all other managed threads will stop their work and will give sign, that GC can start its work.
Threads that are waiting for a handle 000001bc are already waiting for a GC.
All of them have identical top of call stack:
00 049ff670 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
01 049ff6e4 7220a0ab 000001bc ffffffff 00000000 KERNELBASE!WaitForSingleObjectEx+0x99 (FPO: [SEH])
02 049ff714 7220a0f2 00000000 e1a41a23 00000000 clr!CLREventWaitHelper2+0x33 (FPO: [Non-Fpo])
03 049ff764 7220a077 00000000 e1a41adb 0159d398 clr!CLREventWaitHelper+0x2a (FPO: [Non-Fpo])
04 049ff79c 7221499e ffffffff 00000000 00000000 clr!CLREventBase::WaitEx+0x152 (FPO: [Non-Fpo])
05 049ff7b0 72211c25 00000000 e1a41a87 016501e0 clr!WKS::GCHeap::WaitUntilGCComplete+0x34 (FPO: [1,0,0])
06 049ff800 722c53c0 098deaf0 722c9fe6 e1a41527 clr!Thread::RareDisablePreemptiveGC+0x231 (FPO: [0,13,0])
07 049ff808 722c9fe6 e1a41527 00000001 00000000 clr!GCCoopHackNoThread::GCCoopHackNoThread+0x2e (FPO: [0,0,4])
There is a third handle - 00000980 which is blocking threads 6 and 24.
Here are call stacks of these two threads:
6 Id: 22d8.f94 Suspend: 0 Teb: 7e9cc000 Unfrozen
# ChildEBP RetAddr Args to Child
00 07adf63c 7769de07 00000980 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
01 07adf6b0 7769dc8b 0429da58 0429da58 00000002 ntdll!RtlpWaitOnCriticalSection+0xd0 (FPO: [Non-Fpo])
02 07adf6dc 7769dcb5 07adf71c 67691348 67737850 ntdll!RtlpEnterCriticalSectionContended+0xa0 (FPO: [Non-Fpo])
03 07adf6e4 67691348 67737850 f76f5d88 0429da58 ntdll!RtlEnterCriticalSection+0x42 (FPO: [Non-Fpo])
04 07adf71c 6768e470 07adf73c 07adf740 07adf74c ucrtbase!__crt_seh_guarded_call<void>::operator()<<lambda_5b71d36f03204c0beab531769a5b5694>,<lambda_be2b3da3f62db62e9dad5dc70221a656> &,<lambda_8f9ce462984622f9bf76b59e2aaaf805> >+0x48 (FPO: [SEH])
05 07adf754 776ecc7a 0429da58 015b85c8 00000102 ucrtbase!destroy_fls+0xe0 (FPO: [Non-Fpo])
06 07adf77c 776a2dde 015b85c8 e7200ce7 00000000 ntdll!RtlProcessFlsData+0xf8 (FPO: [Non-Fpo])
07 07adf818 776a29dc ffffffff 00000102 74b10000 ntdll!LdrShutdownThread+0x32 (FPO: [SEH])
08 07adf8ec 74f17194 00000000 00000102 74b10000 ntdll!RtlExitUserThread+0x4c (FPO: [Non-Fpo])
09 07adf900 74b1c1c8 74b10000 00000000 74b1c0d0 KERNELBASE!FreeLibraryAndExitThread+0x34 (FPO: [Non-Fpo])
0a 07adf93c 76f57c04 01602f40 76f57be0 e7636a34 mswsock!SockAsyncThread+0x11e (FPO: [Non-Fpo])
0b 07adf950 776dad2f 01602f40 e7200d67 00000000 kernel32!BaseThreadInitThunk+0x24 (FPO: [Non-Fpo])
0c 07adf998 776dacfa ffffffff 776c00b0 00000000 ntdll!__RtlUserThreadStart+0x2f (FPO: [SEH])
0d 07adf9a8 00000000 74b1c0d0 01602f40 00000000 ntdll!_RtlUserThreadStart+0x1b (FPO: [Non-Fpo])
24 Id: 22d8.2ee8 Suspend: 0 Teb: 7ea3c000 Unfrozen
# ChildEBP RetAddr Args to Child
00 096cf77c 7769de07 00000980 00000000 00000000 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
01 096cf7f0 7769dc8b 67737340 075af238 00000002 ntdll!RtlpWaitOnCriticalSection+0xd0 (FPO: [Non-Fpo])
02 096cf81c 7769dcb5 096cf85c 67691598 67737850 ntdll!RtlpEnterCriticalSectionContended+0xa0 (FPO: [Non-Fpo])
03 096cf824 67691598 67737850 f9ae52c8 67737340 ntdll!RtlEnterCriticalSection+0x42 (FPO: [Non-Fpo])
04 096cf85c 6768ed7b 096cf890 096cf87c 096cf884 ucrtbase!__crt_seh_guarded_call<void>::operator()<<lambda_3518db117f0e7cdb002338c5d3c47b6c>,<lambda_b2ea41f6bbb362cd97d94c6828d90b61> &,<lambda_abdedf541bb04549bc734292b4a045d4> >+0x48 (FPO: [SEH])
05 096cf8ac 6768e4f6 00000000 096cf8d8 776c96de ucrtbase!DllMainDispatch+0x17b (FPO: [Non-Fpo])
06 096cf8b8 776c96de 67660000 00000002 00000000 ucrtbase!__acrt_DllMain+0x16 (FPO: [Non-Fpo])
07 096cf8d8 776c9658 6768e4e0 67660000 00000002 ntdll!LdrxCallInitRoutine+0x16
08 096cf928 776e5b33 00000002 00000000 e9e10d3b ntdll!LdrpCallInitRoutine+0x43 (FPO: [SEH])
09 096cf9c4 776daa54 e9e10eeb 00000000 00000000 ntdll!LdrpInitializeThread+0x106 (FPO: [SEH])
0a 096cfa14 776da9d0 00000000 00000000 096cfa30 ntdll!_LdrpInitialize+0x6e (FPO: [Non-Fpo])
0b 096cfa1c 00000000 096cfa30 77680000 00000000 ntdll!LdrInitializeThunk+0x10 (FPO: [Non-Fpo])
The top ich identical. And both are waiting for the same event:
0:024> dt ntdll!_RTL_CRITICAL_SECTION 67737850
+0x000 DebugInfo : 0x07589a98 _RTL_CRITICAL_SECTION_DEBUG
+0x004 LockCount : 0n-10
+0x008 RecursionCount : 0n1
+0x00c OwningThread : 0x000023e8 Void
+0x010 LockSemaphore : 0x00000980 Void
+0x014 SpinCount : 0xfa0
And here I can see, that the owner of this event is thread Nr. 7 (23e8).
And here I've stucked:
thread 0 had triggered GC, and starts waiting for all managed threads
thread 7 had started waiting until GC is finished.
thread 6 seems to be an unmanaged thread, so we can ignore it
thread 24 waits until thread 7 will release handle 0x980
thread 0 will not continue until thread 24 will start to wait for GC (WaitUntilGCComplete)
thread 7 will not release handle 0x980 until thread 0 is ready.
Deadlock.
I don't see any line in callstack of the thread 7 where this handle could be set. And i have no idea, how could i found out the reason of the deadlock.
Do you have any advice?
Update, as requested in comment:
Here is the output of !analyze -v -hang
0:007> !analyze -v -hang
*******************************************************************************
* *
* Exception Analysis *
* *
*******************************************************************************
DUMP_CLASS: 2
DUMP_QUALIFIER: 400
CONTEXT: (.cxr;r)
eax=00000001 ebx=07628058 ecx=00000000 edx=00000000 esi=00000000 edi=000001bc
eip=776bc33c esp=0817d4f4 ebp=0817d564 iopl=0 nv up ei pl nz na po nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000202
ntdll!NtWaitForSingleObject+0xc:
776bc33c c20c00 ret 0Ch
FAULTING_IP:
+0
00000000 ?? ???
EXCEPTION_RECORD: (.exr -1)
ExceptionAddress: 00000000
ExceptionCode: 80000003 (Break instruction exception)
ExceptionFlags: 00000000
NumberParameters: 0
FAULTING_THREAD: 000023e8
PROCESS_NAME: DataAcquisition.exe
ERROR_CODE: (NTSTATUS) 0xcfffffff - <Unable to get error code text>
EXCEPTION_CODE: (NTSTATUS) 0xcfffffff - <Unable to get error code text>
EXCEPTION_CODE_STR: cfffffff
BUGCHECK_STR: APPLICATION_HANG
WATSON_BKT_EVENT: AppHang
WATSON_BKT_MODULE: unknown
WATSON_BKT_MODVER: 0.0.0.0
WATSON_BKT_MODOFFSET: 0
WATSON_BKT_MODSTAMP: bbbbbbb4
WATSON_BKT_PROCSTAMP: 5a7c8dca
WATSON_BKT_PROCVER: 2.0.10.6
PROCESS_VER_PRODUCT: DataAcquisition
BUILD_VERSION_STRING: 6.3.9600.17415 (winblue_r4.141028-1500)
MODLIST_WITH_TSCHKSUM_HASH: 5885d70d8e46f0eabba57b93b12e832f6e89fef5
MODLIST_SHA1_HASH: fee227812939995a1d0ec519e5d34e45f0278989
NTGLOBALFLAG: 0
PROCESS_BAM_CURRENT_THROTTLED: 0
PROCESS_BAM_PREVIOUS_THROTTLED: 0
APPLICATION_VERIFIER_FLAGS: 0
PRODUCT_TYPE: 3
SUITE_MASK: 272
DUMP_FLAGS: 8000c07
DUMP_TYPE: 3
MISSING_CLR_SYMBOL: 0
ANALYSIS_SESSION_HOST: D116761
ANALYSIS_SESSION_TIME: 03-01-2018 18:23:18.0286
ANALYSIS_VERSION: 10.0.15063.400 x86fre
MANAGED_CODE: 1
MANAGED_ENGINE_MODULE: clr
MANAGED_ANALYSIS_PROVIDER: SOS
MANAGED_THREAD_ID: 2e1c
DERIVED_WAIT_CHAIN:
Dl Eid Cid WaitType
-- --- ------- --------------------------
7 22d8.23e8 Pseudo Thread Handle
WAIT_CHAIN_COMMAND: ~7s;k;;
THREAD_ATTRIBUTES:
BLOCKING_THREAD: 000023e8
DEFAULT_BUCKET_ID: APPLICATION_HANG_BusyHang
PRIMARY_PROBLEM_CLASS: BusyHang
THREAD_SHA1_HASH_MOD_FUNC: 9ced3fd11653de6459589f9d85e80a71659b8f04
THREAD_SHA1_HASH_MOD_FUNC_OFFSET: 35554e4c1cf9537ccfa6541f1738ec2b92873870
LAST_CONTROL_TRANSFER: from 74f02cc7 to 776bc33c
STACK_TEXT:
0817d4f0 74f02cc7 000001bc 00000000 00000000 ntdll!NtWaitForSingleObject+0xc
0817d564 7220a0ab 000001bc ffffffff 00000000 KERNELBASE!WaitForSingleObjectEx+0x99
0817d594 7220a0f2 00000000 ed2c38a3 00000000 clr!CLREventWaitHelper2+0x33
0817d5e4 7220a077 00000000 ed2c3b5b 0159d398 clr!CLREventWaitHelper+0x2a
0817d61c 7221499e ffffffff 00000000 00000000 clr!CLREventBase::WaitEx+0x152
0817d630 72211c25 00000000 ed2c3b07 07628058 clr!WKS::GCHeap::WaitUntilGCComplete+0x34
0817d680 72388444 ed2c3a43 00000000 07628058 clr!Thread::RareDisablePreemptiveGC+0x231
0817d704 0829e382 3259f8be 721ffa00 0817d748 clr!JIT_RareDisableHelper+0x24
WARNING: Frame IP not in any known module. Following frames may be wrong.
0817d738 0829e1fe 0829e231 3259f8be 721ffa00 0x829e382
0817d7a4 0829de54 00000014 0817da54 0817d830 0x829e1fe
0817d830 09518e12 0817de98 01e9d821 00000030 0x829de54
0817db2c 095180bc 0817de98 04230d90 0817f350 0x9518e12
0817e044 0437bf99 0817ead0 095488f0 07628058 0x95180bc
0817e070 09513481 0758e698 0817f350 0817ead0 0x437bf99
0817ee94 09545fa9 0817f2c0 00000000 0817f5e4 0x9513481
0817f638 081fb947 0817f82c 097b5d38 3259f8be 0x9545fa9
0817f6b8 0437b535 0817f82c 081f68e0 07628058 0x81fb947
0817f6e4 081fa751 04259828 097b5d38 0817f82c 0x437b535
0817f78c 0437b1fc 0817f814 0817f80c 081f6870 0x81fa751
0817f7bc 0802e1c4 04259828 0817f82c 0817f80c 0x437b1fc
0817f888 0437a01d 0802c4f0 07628058 0817fb9c 0x802e1c4
0817f8b0 0802d897 04259828 07628058 04264ec0 0x437a01d
0817fb8c 04379f56 0802c4d8 07628058 0817fc14 0x802d897
0817fbb4 0802cf80 04259828 3259f8be 721ffa00 0x4379f56
0817fbe8 0802cf1b 00000000 0817fbfc 0817fc2c 0x802cf80
0817fc2c 734ebb5e 04230de0 ecec8d35 04264ec0 0x802cf1b
0817fc58 676e62e4 04230de0 f8d55600 676e6290 boost_thread_vc140_mt_1_60!boost::detail::win32::handle_manager::swap+0x7e
0817fc94 76f57c04 04264ec0 76f57be0 e8d96fcc ucrtbase!thread_start<unsigned int (__stdcall*)(void *)>+0x54
0817fca8 776dad2f 04264ec0 e89a080f 00000000 kernel32!BaseThreadInitThunk+0x24
0817fcf0 776dacfa ffffffff 776c00b0 00000000 ntdll!__RtlUserThreadStart+0x2f
0817fd00 00000000 676e6290 04264ec0 00000000 ntdll!_RtlUserThreadStart+0x1b
THREAD_SHA1_HASH_MOD: 9c5af7c316b52dce74c542a777786aa1292e9273
FOLLOWUP_IP:
clr!Thread::RareDisablePreemptiveGC+231
72211c25 83a388000000ef and dword ptr [ebx+88h],0FFFFFFEFh
FAULT_INSTR_CODE: 88a383
SYMBOL_STACK_INDEX: 6
SYMBOL_NAME: clr!Thread::RareDisablePreemptiveGC+231
FOLLOWUP_NAME: MachineOwner
MODULE_NAME: clr
IMAGE_NAME: clr.dll
DEBUG_FLR_IMAGE_TIMESTAMP: 59cf5105
STACK_COMMAND: ~7s ; kb
BUCKET_ID: APPLICATION_HANG_clr!Thread::RareDisablePreemptiveGC+231
FAILURE_EXCEPTION_CODE: cfffffff
FAILURE_IMAGE_NAME: clr.dll
BUCKET_ID_IMAGE_STR: clr.dll
FAILURE_MODULE_NAME: clr
BUCKET_ID_MODULE_STR: clr
FAILURE_FUNCTION_NAME: Thread::RareDisablePreemptiveGC
BUCKET_ID_FUNCTION_STR: Thread::RareDisablePreemptiveGC
BUCKET_ID_OFFSET: 231
BUCKET_ID_MODPRIVATE: 1
BUCKET_ID_MODTIMEDATESTAMP: 59cf5105
BUCKET_ID_MODCHECKSUM: 6e5783
BUCKET_ID_MODVER_STR: 4.7.2117.0
BUCKET_ID_PREFIX_STR: APPLICATION_HANG_
FAILURE_PROBLEM_CLASS: BusyHang
FAILURE_SYMBOL_NAME: clr.dll!Thread::RareDisablePreemptiveGC
FAILURE_BUCKET_ID: APPLICATION_HANG_BusyHang_cfffffff_clr.dll!Thread::RareDisablePreemptiveGC
TARGET_TIME: 2018-02-28T03:14:53.000Z
OSBUILD: 9600
OSSERVICEPACK: 17415
SERVICEPACK_NUMBER: 0
OS_REVISION: 0
OSPLATFORM_TYPE: x86
OSNAME: Windows 8.1
OSEDITION: Windows 8.1 Server TerminalServer SingleUserTS
OS_LOCALE:
USER_LCID: 0
OSBUILD_TIMESTAMP: 2014-10-29 02:58:22
BUILDDATESTAMP_STR: 141028-1500
BUILDLAB_STR: winblue_r4
BUILDOSVER_STR: 6.3.9600.17415
ANALYSIS_SESSION_ELAPSED_TIME: 5a7d
ANALYSIS_SOURCE: UM
FAILURE_ID_HASH_STRING: um:application_hang_busyhang_cfffffff_clr.dll!thread::raredisablepreemptivegc
FAILURE_ID_HASH: {6a1ff91c-492b-fc00-85f1-6b17a6a44ff6}
Followup: MachineOwner
---------
Update 2:
I've noticed, that all threads are start with ntdll!_RtlUserThreadStart and thread 24 starts with ntdll!LdrInitializeThunk. Could this information give an advice how thread 24 was started? What is the difference between these entry points?

Running Intel 7260 in AP mode under Ubuntu 14.04

I would like to use the built-in WiFi on a Gigabyte mini-ITX system I just bought as an access point. And for some reason I am going in circles.
lspci | grep -i wireless reveals:
04:00.0 Network controller: Intel Corporation Wireless 7260 (rev 73)
lsmod | grep 80211 gives:
mac80211 630669 1 iwlmvm
cfg80211 484040 3 iwlwifi,mac80211,iwlmvm
I installed hostapd. Here is the (more than) minimal hostapd.conf I created:
interface=wlan0
driver=nl80211
logger_syslog=-1
logger_syslog_level=2
logger_stdout=-1
logger_stdout_level=2
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
ssid=test
hw_mode=g
channel=1
beacon_int=100
dtim_period=2
max_num_sta=255
rts_threshold=2347
fragm_threshold=2346
macaddr_acl=0
auth_algs=3
ignore_broadcast_ssid=0
wmm_enabled=1
wmm_ac_bk_cwmin=4
wmm_ac_bk_cwmax=10
wmm_ac_bk_aifs=7
wmm_ac_bk_txop_limit=0
wmm_ac_bk_acm=0
wmm_ac_be_aifs=3
wmm_ac_be_cwmin=4
wmm_ac_be_cwmax=10
wmm_ac_be_txop_limit=0
wmm_ac_be_acm=0
wmm_ac_vi_aifs=2
wmm_ac_vi_cwmin=3
wmm_ac_vi_cwmax=4
wmm_ac_vi_txop_limit=94
wmm_ac_vi_acm=0
wmm_ac_vo_aifs=2
wmm_ac_vo_cwmin=2
wmm_ac_vo_cwmax=3
wmm_ac_vo_txop_limit=47
own_ip_addr=127.0.0.1
When I try to run hostapd, I get this:
$ sudo hostapd ./hostapd.conf
Configuration file: ./hostapd.conf
nl80211: Could not configure driver mode
nl80211 driver initialization failed.
hostapd_free_hapd_data: Interface wlan0 wasn't started
So, I read there was a problem with Ubuntu 14.04 and how to get around it.
https://bugs.launchpad.net/ubuntu/+source/wpa/+bug/1289047
Interestingly it appears that now the driver (version 2.1) does something with error, and before it ignored it.
a solution (in desktop cases) is to do following to release resource.. then hostapd has no error....
sudo nmcli nm wifi off
sudo rfkill unblock wlan
this info has been gleaned from https://bbs.archlinux.org/viewtopic.php?pid=1221799
nmcli is part of network-manager, which needed to be installed.
Next,
/etc/hostapd$ sudo nmcli nm wifi off
** (process:5724): WARNING **: Could not initialize NMClient /org/freedesktop/NetworkManager: The name org.freedesktop.NetworkManager was not provided by any .service files
So I ran these commands, which are supposedly a workaround.
/etc/hostapd$ sudo service network-manager start
network-manager start/running, process 5763
/etc/hostapd$ sudo nmcli nm wifi off
/etc/hostapd$ sudo rfkill unblock wlan
But still the same problem with trying to run hostapd.
https://askubuntu.com/questions/472794/hostapd-error-nl80211-could-not-configure-driver-mode recommends this:
sudo ifconfig wlan0 10.15.0.1/24 up
sleep 1
sudo service isc-dhcp-server restart
sudo service hostapd restart
isc-dhcp-server is not yet installed. Everything else ran without showing any error.
Still having the problem though!
ifconfig wlan0 shows:
wlan0 Link encap:Ethernet HWaddr 80:19:34:32:20:a3
inet addr:10.15.0.1 Bcast:10.15.0.255 Mask:255.255.255.0
inet6 addr: fd04:bd3:80e8:1:91e9:7f2e:f005:5af9/64 Scope:Global
inet6 addr: fe80::8219:34ff:fe32:20a3/64 Scope:Link
inet6 addr: fd04:bd3:80e8:1:8219:34ff:fe32:20a3/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:43138 errors:0 dropped:0 overruns:0 frame:0
TX packets:638 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6824297 (6.8 MB) TX bytes:121399 (121.3 KB)
iw list shows:
Wiphy phy0
Band 1:
Capabilities: 0x1062
HT20/HT40
Static SM Power Save
RX HT20 SGI
RX HT40 SGI
No RX STBC
Max AMSDU length: 3839 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 4 usec (0x05)
HT TX/RX MCS rate indexes supported: 0-15, 32
Frequencies:
* 2412 MHz [1] (22.0 dBm)
* 2417 MHz [2] (22.0 dBm)
* 2422 MHz [3] (22.0 dBm)
* 2427 MHz [4] (22.0 dBm)
* 2432 MHz [5] (22.0 dBm)
* 2437 MHz [6] (22.0 dBm)
* 2442 MHz [7] (22.0 dBm)
* 2447 MHz [8] (22.0 dBm)
* 2452 MHz [9] (22.0 dBm)
* 2457 MHz [10] (22.0 dBm)
* 2462 MHz [11] (22.0 dBm)
* 2467 MHz [12] (22.0 dBm) (passive scanning, no IBSS)
* 2472 MHz [13] (22.0 dBm) (passive scanning, no IBSS)
Bitrates (non-HT):
* 1.0 Mbps
* 2.0 Mbps (short preamble supported)
* 5.5 Mbps (short preamble supported)
* 11.0 Mbps (short preamble supported)
* 6.0 Mbps
* 9.0 Mbps
* 12.0 Mbps
* 18.0 Mbps
* 24.0 Mbps
* 36.0 Mbps
* 48.0 Mbps
* 54.0 Mbps
Band 2:
Capabilities: 0x1062
HT20/HT40
Static SM Power Save
RX HT20 SGI
RX HT40 SGI
No RX STBC
Max AMSDU length: 3839 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 4 usec (0x05)
HT TX/RX MCS rate indexes supported: 0-15, 32
Frequencies:
* 5180 MHz [36] (22.0 dBm) (passive scanning, no IBSS)
* 5200 MHz [40] (22.0 dBm) (passive scanning, no IBSS)
* 5220 MHz [44] (22.0 dBm) (passive scanning, no IBSS)
* 5240 MHz [48] (22.0 dBm) (passive scanning, no IBSS)
* 5260 MHz [52] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5280 MHz [56] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5300 MHz [60] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5320 MHz [64] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5500 MHz [100] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5520 MHz [104] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5540 MHz [108] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5560 MHz [112] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5580 MHz [116] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5600 MHz [120] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5620 MHz [124] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5640 MHz [128] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5660 MHz [132] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5680 MHz [136] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5700 MHz [140] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5720 MHz [144] (22.0 dBm) (passive scanning, no IBSS, radar detection)
* 5745 MHz [149] (22.0 dBm) (passive scanning, no IBSS)
* 5765 MHz [153] (22.0 dBm) (passive scanning, no IBSS)
* 5785 MHz [157] (22.0 dBm) (passive scanning, no IBSS)
* 5805 MHz [161] (22.0 dBm) (passive scanning, no IBSS)
* 5825 MHz [165] (22.0 dBm) (passive scanning, no IBSS)
Bitrates (non-HT):
* 6.0 Mbps
* 9.0 Mbps
* 12.0 Mbps
* 18.0 Mbps
* 24.0 Mbps
* 36.0 Mbps
* 48.0 Mbps
* 54.0 Mbps
max # scan SSIDs: 20
max scan IEs length: 393 bytes
Coverage class: 0 (up to 0m)
Supported Ciphers:
* WEP40 (00-0f-ac:1)
* WEP104 (00-0f-ac:5)
* TKIP (00-0f-ac:2)
* CCMP (00-0f-ac:4)
* CMAC (00-0f-ac:6)
Available Antennas: TX 0 RX 0
Supported interface modes:
* IBSS
* managed
* AP
* AP/VLAN
* monitor
* P2P-client
* P2P-GO
* Unknown mode (10)
software interface modes (can always be added):
* AP/VLAN
* monitor
valid interface combinations:
* #{ managed } <= 1, #{ AP, P2P-client, P2P-GO } <= 1, #{ Unknown mode (10) } <= 1,
total <= 3, #channels <= 1
Supported commands:
* new_interface
* set_interface
* new_key
* new_beacon
* new_station
* new_mpath
* set_mesh_params
* set_bss
* authenticate
* associate
* deauthenticate
* disassociate
* join_ibss
* join_mesh
* remain_on_channel
* set_tx_bitrate_mask
* action
* frame_wait_cancel
* set_wiphy_netns
* set_channel
* set_wds_peer
* Unknown command (84)
* Unknown command (87)
* Unknown command (85)
* Unknown command (89)
* Unknown command (92)
* connect
* disconnect
Supported TX frame types:
* IBSS: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* managed: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* AP: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* AP/VLAN: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* mesh point: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* P2P-client: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* P2P-GO: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* Unknown mode (10): 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
Supported RX frame types:
* IBSS: 0x40 0xb0 0xc0 0xd0
* managed: 0x40 0xd0
* AP: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
* AP/VLAN: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
* mesh point: 0xb0 0xc0 0xd0
* P2P-client: 0x40 0xd0
* P2P-GO: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
* Unknown mode (10): 0x40 0xd0
Device supports RSN-IBSS.
WoWLAN support:
* wake up on disconnect
* wake up on magic packet
* wake up on pattern match, up to 20 patterns of 16-128 bytes
* can do GTK rekeying
* wake up on GTK rekey failure
* wake up on EAP identity request
* wake up on 4-way handshake
* wake up on rfkill release
HT Capability overrides:
* MCS: ff ff ff ff ff ff ff ff ff ff
* maximum A-MSDU length
* supported channel width
* short GI for 40 MHz
* max A-MPDU length exponent
* min MPDU start spacing
Device supports TX status socket option.
Device supports HT-IBSS.
Using iwconfig to set it to "Master" mode, which I think means to set it to AP mode, results in this:
$ sudo iwconfig wlan0 mode Master
Error for wireless request "Set Mode" (8B06) :
SET failed on device wlan0 ; Invalid argument.
So, I guess it's possible that the 7260 driver does not want to work in AP mode. However, the iwlist command output shows AP mode as one of the possibilities.
(Question solved by edit. Converted to community wiki answer.)
The OP wrote:
All right, looks like happy day, I just needed to add this:
### Set your bridge name ###
bridge=br0
to the hostapd.conf file. Now I get:
$ sudo hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
Using interface wlan0 with hwaddr 80:19:34:32:20:a3 and ssid "test"
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED

mmap and then munmap, sometimes unmapped region can be accessed

I met this problem on vmware 11.0 and linux-2.6.34, with gcc 4.9.2, had not tested on real hardware.
Following code run successfully and message were printed without SIGSEGV. But if I uncommented the printf before munmap, a SIGSEGV were caught.
maps before and after munmap() were printed in following messages.
static void check_mmap(void){
int fd, i;
char *p = NULL;
if ((fd = shm_open("xxxxxxxxxxxx", O_RDWR|O_CREAT|O_TRUNC, 0666)) == -1) {
printf("open shm file failed.\n");
return;
}
if (ftruncate(fd, 4096) == -1)
goto out;
p = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
if (MAP_FAILED == p)
goto out;
//printf("Mapped at %p\n", p);
getchar(); // <----- chance to print maps befor munmap
if (munmap(p, 4096) != 0)
printf("munmap error: %s\n", strerror(errno));
printf("Corrupting mmap memory.\n");
for(i = 0; i < 4095; i ++)
p[i] = 0;
printf("Done\n");
getchar(); // <----- chance to print maps after munmap
out:
close(fd);
if (p)
munmap(p, 4096);
}
maps before munmap, shm xxxxxxxxxxxx is mmaped at 7f3f2683a000-7f3f2683b000
00400000-00401000 r-xp 00000000 00:14 121 /mnt/hgfs/vm_shared/asan/asan1
00600000-00601000 rw-p 00000000 00:14 121 /mnt/hgfs/vm_shared/asan/asan1
7f3f25ea6000-7f3f25ebd000 r-xp 00000000 08:02 347266 /lib64/libpthread-2.11.3.so
7f3f25ebd000-7f3f260bc000 ---p 00017000 08:02 347266 /lib64/libpthread-2.11.3.so
7f3f260bc000-7f3f260bd000 r--p 00016000 08:02 347266 /lib64/libpthread-2.11.3.so
7f3f260bd000-7f3f260be000 rw-p 00017000 08:02 347266 /lib64/libpthread-2.11.3.so
7f3f260be000-7f3f260c2000 rw-p 00000000 00:00 0
7f3f260c2000-7f3f2620e000 r-xp 00000000 08:02 298091 /lib64/libc-2.11.1.so
7f3f2620e000-7f3f2640d000 ---p 0014c000 08:02 298091 /lib64/libc-2.11.1.so
7f3f2640d000-7f3f26411000 r--p 0014b000 08:02 298091 /lib64/libc-2.11.1.so
7f3f26411000-7f3f26412000 rw-p 0014f000 08:02 298091 /lib64/libc-2.11.1.so
7f3f26412000-7f3f26417000 rw-p 00000000 00:00 0
7f3f26417000-7f3f2641e000 r-xp 00000000 08:02 335978 /lib64/librt-2.11.1.so
7f3f2641e000-7f3f2661d000 ---p 00007000 08:02 335978 /lib64/librt-2.11.1.so
7f3f2661d000-7f3f2661e000 r--p 00006000 08:02 335978 /lib64/librt-2.11.1.so
7f3f2661e000-7f3f2661f000 rw-p 00007000 08:02 335978 /lib64/librt-2.11.1.so
7f3f2661f000-7f3f2663d000 r-xp 00000000 08:02 260202 /lib64/ld-2.11.1.so
7f3f2682b000-7f3f2682e000 rw-p 00000000 00:00 0
7f3f26839000-7f3f2683a000 rw-p 00000000 00:00 0
7f3f2683a000-7f3f2683b000 rw-p 00000000 00:11 16078 /dev/shm/xxxxxxxxxxxx
7f3f2683b000-7f3f2683c000 rw-p 00000000 00:00 0
7f3f2683c000-7f3f2683d000 r--p 0001d000 08:02 260202 /lib64/ld-2.11.1.so
7f3f2683d000-7f3f2683e000 rw-p 0001e000 08:02 260202 /lib64/ld-2.11.1.so
7f3f2683e000-7f3f2683f000 rw-p 00000000 00:00 0
7fffd9ce3000-7fffd9d04000 rw-p 00000000 00:00 0 [stack]
7fffd9dff000-7fffd9e00000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
maps after munmap, shm was successfully unmapped.
00400000-00401000 r-xp 00000000 00:14 121 /mnt/hgfs/vm_shared/asan/asan1
00600000-00601000 rw-p 00000000 00:14 121 /mnt/hgfs/vm_shared/asan/asan1
7f3f25ea6000-7f3f25ebd000 r-xp 00000000 08:02 347266 /lib64/libpthread-2.11.3.so
7f3f25ebd000-7f3f260bc000 ---p 00017000 08:02 347266 /lib64/libpthread-2.11.3.so
7f3f260bc000-7f3f260bd000 r--p 00016000 08:02 347266 /lib64/libpthread-2.11.3.so
7f3f260bd000-7f3f260be000 rw-p 00017000 08:02 347266 /lib64/libpthread-2.11.3.so
7f3f260be000-7f3f260c2000 rw-p 00000000 00:00 0
7f3f260c2000-7f3f2620e000 r-xp 00000000 08:02 298091 /lib64/libc-2.11.1.so
7f3f2620e000-7f3f2640d000 ---p 0014c000 08:02 298091 /lib64/libc-2.11.1.so
7f3f2640d000-7f3f26411000 r--p 0014b000 08:02 298091 /lib64/libc-2.11.1.so
7f3f26411000-7f3f26412000 rw-p 0014f000 08:02 298091 /lib64/libc-2.11.1.so
7f3f26412000-7f3f26417000 rw-p 00000000 00:00 0
7f3f26417000-7f3f2641e000 r-xp 00000000 08:02 335978 /lib64/librt-2.11.1.so
7f3f2641e000-7f3f2661d000 ---p 00007000 08:02 335978 /lib64/librt-2.11.1.so
7f3f2661d000-7f3f2661e000 r--p 00006000 08:02 335978 /lib64/librt-2.11.1.so
7f3f2661e000-7f3f2661f000 rw-p 00007000 08:02 335978 /lib64/librt-2.11.1.so
7f3f2661f000-7f3f2663d000 r-xp 00000000 08:02 260202 /lib64/ld-2.11.1.so
7f3f2682b000-7f3f2682e000 rw-p 00000000 00:00 0
7f3f26839000-7f3f2683b000 rw-p 00000000 00:00 0
7f3f2683b000-7f3f2683c000 rw-p 00000000 00:00 0
7f3f2683c000-7f3f2683d000 r--p 0001d000 08:02 260202 /lib64/ld-2.11.1.so
7f3f2683d000-7f3f2683e000 rw-p 0001e000 08:02 260202 /lib64/ld-2.11.1.so
7f3f2683e000-7f3f2683f000 rw-p 00000000 00:00 0
7fffd9ce3000-7fffd9d04000 rw-p 00000000 00:00 0 [stack]
7fffd9dff000-7fffd9e00000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
following is objdump
0000000000400890 <main>:
400890: 55 push %rbp
400891: 53 push %rbx
400892: ba b6 01 00 00 mov $0x1b6,%edx
400897: be 42 02 00 00 mov $0x242,%esi
40089c: bf 9c 0a 40 00 mov $0x400a9c,%edi
4008a1: 48 83 ec 08 sub $0x8,%rsp
4008a5: e8 fe fd ff ff callq 4006a8 <shm_open#plt>
4008aa: 83 f8 ff cmp $0xffffffffffffffff,%eax
4008ad: 89 c3 mov %eax,%ebx
4008af: 0f 84 c0 00 00 00 je 400975 <main+0xe5>
4008b5: be 00 10 00 00 mov $0x1000,%esi
4008ba: 89 c7 mov %eax,%edi
4008bc: e8 37 fe ff ff callq 4006f8 <ftruncate#plt>
4008c1: 83 f8 ff cmp $0xffffffffffffffff,%eax
4008c4: 0f 84 9b 00 00 00 je 400965 <main+0xd5>
4008ca: 45 31 c9 xor %r9d,%r9d
4008cd: 31 ff xor %edi,%edi
4008cf: 41 89 d8 mov %ebx,%r8d
4008d2: b9 02 00 00 00 mov $0x2,%ecx
4008d7: ba 03 00 00 00 mov $0x3,%edx
4008dc: be 00 10 00 00 mov $0x1000,%esi
4008e1: e8 22 fe ff ff callq 400708 <mmap#plt>
4008e6: 48 83 f8 ff cmp $0xffffffffffffffff,%rax
4008ea: 48 89 c5 mov %rax,%rbp
4008ed: 0f 84 8e 00 00 00 je 400981 <main+0xf1>
4008f3: 48 8b 3d 0e 05 20 00 mov 0x20050e(%rip),%rdi # 600e08 <__TMC_END__>
4008fa: e8 b9 fd ff ff callq 4006b8 <_IO_getc#plt>
4008ff: be 00 10 00 00 mov $0x1000,%esi
400904: 48 89 ef mov %rbp,%rdi
400907: e8 dc fd ff ff callq 4006e8 <munmap#plt>
40090c: 85 c0 test %eax,%eax
40090e: 75 7a jne 40098a <main+0xfa>
400910: bf d1 0a 40 00 mov $0x400ad1,%edi
400915: e8 6e fd ff ff callq 400688 <puts#plt>
40091a: 48 8d 8d ff 0f 00 00 lea 0xfff(%rbp),%rcx
400921: 48 89 ea mov %rbp,%rdx
400924: 0f 1f 40 00 nopl 0x0(%rax)
400928: c6 02 00 movb $0x0,(%rdx)
40092b: 48 83 c2 01 add $0x1,%rdx
40092f: 48 39 ca cmp %rcx,%rdx
400932: 75 f4 jne 400928 <main+0x98>
400934: bf e9 0a 40 00 mov $0x400ae9,%edi
400939: e8 4a fd ff ff callq 400688 <puts#plt>
40093e: 48 8b 3d c3 04 20 00 mov 0x2004c3(%rip),%rdi # 600e08 <__TMC_END__>
400945: e8 6e fd ff ff callq 4006b8 <_IO_getc#plt>
You're invoking "undefined behavior." Anything could happen. You can't then complain that in one case you like the result more than in another case when both have undefined behavior. Just stop running invalid code.
Following code run successfully and message were printed without
SIGSEGV. But if I uncommented the printf before munmap, a SIGSEGV were
caught.
This prima facie startling behavior has a simple explanation. A Segmentation fault is indeed to be expected when accessing unmapped Linux memory. It's just that without the printf before munmap, the printf("Corrupting mmap memory.\n") after munmap() constitutes the program's first use of stdout, and on that first use, the Linux/GNU C library allocates a stream buffer by means of mmap(), thereby re-mapping exactly the memory page that was unmapped just before, so p[i] can access the anew mapped memory without a fault.

Resources