<div dir="ltr">FYI, here is another POC that can trigger the crash when 1, 2, 3, 4 threads are specified on my machine.<div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><font color="#313131" face="Arial, sans-serif"><span style="font-size:12px">Best Regards,</span></font><div><font color="#313131" face="Arial, sans-serif"><span style="font-size:12px">Hongxu</span></font></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 8, 2019 at 2:35 PM Hongxu Chen <<a href="mailto:leftcopy.chx@gmail.com">leftcopy.chx@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi,</div><div><br></div><div> On my machine, when running x264 (sandbox version, git HEAD d4099dd4c722f52c4f3c14575d7d39eb8fadb97f) with 4 threads, it may cause a heap-buffer-overflow at encoder/me.c:244.</div><div><br></div><div>$ ./x264-asan/install/bin/x264 --threads 4 --quiet --output /dev/null x264_poc</div><div><div>=================================================================</div><div>==32524==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x621000031d20 at pc 0x00000074ce72 bp 0x7fe714073df0 sp 0x7fe714073de8</div><div>READ of size 2 at 0x621000031d20 thread T2</div><div> #0 0x74ce71 in x264_8_me_search_ref /home/hongxu/work/x264/x264-asan/encoder/me.c:244:21</div><div> #1 0x6df538 in mb_analyse_inter_p16x16 /home/hongxu/work/x264/x264-asan/encoder/analyse.c:1275:13</div><div> #2 0x6df538 in x264_8_macroblock_analyse /home/hongxu/work/x264/x264-asan/encoder/analyse.c:3026</div><div> #3 0x59f274 in slice_write /home/hongxu/work/x264/x264-asan/encoder/encoder.c:2775:9</div><div> #4 0x591bee in slices_write /home/hongxu/work/x264/x264-asan/encoder/encoder.c:3116:13</div><div> #5 0x5a9fdf in threadpool_thread_internal /home/hongxu/work/x264/x264-asan/common/threadpool.c:69:20</div><div> #6 0x5fefeb in x264_stack_align (/home/hongxu/work/x264/x264-asan/install/bin/x264+0x5fefeb)</div><div><br></div><div>0x621000031d20 is located 30 bytes to the right of 4098-byte region [0x621000030d00,0x621000031d02)</div><div>allocated by thread T0 here:</div><div> #0 0x4d4948 in __interceptor_memalign.localalias.1 (/home/hongxu/work/x264/x264-asan/install/bin/x264+0x4d4948)</div><div> #1 0x548fcc in x264_malloc /home/hongxu/work/x264/x264-asan/common/base.c:124:21</div><div><br></div><div>Thread T2 created by T0 here:</div><div> #0 0x4377a0 in pthread_create (/home/hongxu/work/x264/x264-asan/install/bin/x264+0x4377a0)</div><div> #1 0x5a96e9 in x264_8_threadpool_init /home/hongxu/work/x264/x264-asan/common/threadpool.c:111:13</div><div><br></div><div>SUMMARY: AddressSanitizer: heap-buffer-overflow /home/hongxu/work/x264/x264-asan/encoder/me.c:244:21 in x264_8_me_search_ref</div><div>Shadow bytes around the buggy address:</div><div> 0x0c427fffe350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00</div><div> 0x0c427fffe360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00</div><div> 0x0c427fffe370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00</div><div> 0x0c427fffe380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00</div><div> 0x0c427fffe390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00</div><div>=>0x0c427fffe3a0: 02 fa fa fa[fa]fa fa fa fa fa fa fa fa fa fa fa</div><div> 0x0c427fffe3b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa</div><div> 0x0c427fffe3c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa</div><div> 0x0c427fffe3d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa</div><div> 0x0c427fffe3e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa</div><div> 0x0c427fffe3f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa</div><div>Shadow byte legend (one shadow byte represents 8 application bytes):</div><div> Addressable: 00</div><div> Partially addressable: 01 02 03 04 05 06 07 </div><div> Heap left redzone: fa</div><div> Freed heap region: fd</div><div> Stack left redzone: f1</div><div> Stack mid redzone: f2</div><div> Stack right redzone: f3</div><div> Stack after return: f5</div><div> Stack use after scope: f8</div><div> Global redzone: f9</div><div> Global init order: f6</div><div> Poisoned by user: f7</div><div> Container overflow: fc</div><div> Array cookie: ac</div><div> Intra object redzone: bb</div><div> ASan internal: fe</div><div> Left alloca redzone: ca</div><div> Right alloca redzone: cb</div><div>==32524==ABORTING</div><div>[1] 32524 abort ./x264-asan/install/bin/x264 --threads 4 --quiet --output /dev/null x264_poc</div></div><div><br></div><div>Till now, I can only see the crash stably when x264 is compiled with AddressSanitizer and run with 4 threads.</div><br clear="all"><div><div dir="ltr" class="gmail-m_-3493368451796627447gmail_signature"><div dir="ltr"><div><div dir="ltr"><font color="#313131" face="Arial, sans-serif"><span style="font-size:12px">Best Regards,</span></font><div><font color="#313131" face="Arial, sans-serif"><span style="font-size:12px">Hongxu</span></font></div></div></div></div></div></div></div></div></div></div></div></div>
</blockquote></div>