#9924 closed defect (fixed)

drawbox replace vs rgba

Reported by: Jozef Chutka Owned by:
Priority: important Component: avfilter
Version: git-master Keywords: drawbox crash SIGSEGV
Cc: Jozef Chutka Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Using ffmpeg version 2022-09-07-git-e4c1272711-full_build-www.gyan.dev

Following command does not generate an output file:

ffmpeg -f lavfi -i color=color=#00000000:size=100x100 -vf "format=rgba,drawbox=c=blue:h=50:w=50:replace=1" -frames:v 1 -y out.png

Log contains no errors:

ffmpeg version 2022-09-07-git-e4c1272711-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      57. 36.101 / 57. 36.101
  libavcodec     59. 42.104 / 59. 42.104
  libavformat    59. 30.101 / 59. 30.101
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 48.100 /  8. 48.100
  libswscale      6.  8.108 /  6.  8.108
  libswresample   4.  9.100 /  4.  9.100
  libpostproc    56.  7.100 / 56.  7.100
Input #0, lavfi, from 'color=color=#00000000:size=100x100':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: wrapped_avframe, yuv420p, 100x100 [SAR 1:1 DAR 1:1], 25 fps, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (wrapped_avframe (native) -> png (native))
Press [q] to stop, [?] for help

If either format=rgba is removed or :replace=1 removed it works.

According to the doc, replace:
Applicable if the input has alpha. With value 1, the pixels of the painted box will overwrite the video’s color and alpha pixels. Default is 0, which composites the box onto the input, leaving the video’s alpha intact.

The problem is that it does not seem to work with rgba.

Change History (3)

comment:1 by Elon Musk, 21 months ago

Isnt this crashing?

comment:2 by Carl Eugen Hoyos, 21 months ago

Component: undeterminedavfilter
Keywords: crash SIGSEGV added
Priority: normalimportant
Reproduced by developer: set
Version: unspecifiedgit-master
(gdb) r -f lavfi -i color=color=#00000000:size=100x100 -vf "format=rgba,drawbox=c=blue:h=50:w=50:replace=1" -frames:v 1 -f null -
Starting program: ffmpeg_g -f lavfi -i color=color=#00000000:size=100x100 -vf "format=rgba,drawbox=c=blue:h=50:w=50:replace=1" -frames:v 1 -f null -
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
ffmpeg version N-108141-g859b31de50 Copyright (c) 2000-2022 the FFmpeg developers
  built with clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
  configuration: --enable-gpl --cc=clang
  libavutil      57. 36.101 / 57. 36.101
  libavcodec     59. 43.100 / 59. 43.100
  libavformat    59. 31.100 / 59. 31.100
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 49.100 /  8. 49.100
  libswscale      6.  8.112 /  6.  8.112
  libswresample   4.  9.100 /  4.  9.100
  libpostproc    56.  7.100 / 56.  7.100
[New Thread 0x7ffffe810700 (LWP 20344)]
[New Thread 0x7ffffe000700 (LWP 20345)]
[New Thread 0x7ffffd7f0700 (LWP 20346)]
[New Thread 0x7ffffcfe0700 (LWP 20347)]
[New Thread 0x7ffffc7d0700 (LWP 20348)]
[New Thread 0x7ffffbfc0700 (LWP 20349)]
[New Thread 0x7ffffb7b0700 (LWP 20350)]
[New Thread 0x7ffffafa0700 (LWP 20351)]
Input #0, lavfi, from 'color=color=#00000000:size=100x100':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: wrapped_avframe, yuv420p, 100x100 [SAR 1:1 DAR 1:1], 25 fps, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (wrapped_avframe (native) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
[New Thread 0x7ffffa790700 (LWP 20352)]
[New Thread 0x7ffff9f80700 (LWP 20353)]
[New Thread 0x7ffff9770700 (LWP 20354)]
[New Thread 0x7ffff8f60700 (LWP 20355)]
[New Thread 0x7ffff3ff0700 (LWP 20356)]
[New Thread 0x7ffff37e0700 (LWP 20357)]
[New Thread 0x7ffff2fd0700 (LWP 20358)]
[New Thread 0x7ffff27c0700 (LWP 20359)]
[New Thread 0x7ffff1fb0700 (LWP 20360)]
[New Thread 0x7ffff17a0700 (LWP 20361)]
[New Thread 0x7ffff0f90700 (LWP 20362)]
[New Thread 0x7ffff0780700 (LWP 20363)]
[New Thread 0x7fffeff70700 (LWP 20364)]
[New Thread 0x7fffef760700 (LWP 20365)]
[New Thread 0x7fffeef50700 (LWP 20366)]
[New Thread 0x7fffee740700 (LWP 20367)]
[New Thread 0x7fffedf30700 (LWP 20368)]

Thread 1 "ffmpeg_g" received signal SIGSEGV, Segmentation fault.
0x0000000000518a4f in draw_region_rgb_packed (frame=0x24a4100, ctx=0x23cca40, left=0, top=<optimized out>, right=50, down=50,
    pixel_belongs_to_region=0x5184c0 <pixel_belongs_to_box>) at src/libavfilter/vf_drawbox.c:188
188                             row[1][x*C] = ctx->rgba_color[G];
(gdb) bt
#0  0x0000000000518a4f in draw_region_rgb_packed (frame=0x24a4100, ctx=0x23cca40, left=0, top=<optimized out>, right=50, down=50, pixel_belongs_to_region=0x5184c0 <pixel_belongs_to_box>) at src/libavfilter/vf_drawbox.c:188
#1  0x0000000000517fd1 in filter_frame (inlink=<optimized out>, frame=0x24a4100) at src/libavfilter/vf_drawbox.c:401
#2  0x0000000000459f25 in ff_filter_frame_framed (link=<optimized out>, frame=<optimized out>) at src/libavfilter/avfilter.c:1000
#3  ff_filter_frame_to_filter (link=<optimized out>) at src/libavfilter/avfilter.c:1144
#4  ff_filter_activate_default (filter=<optimized out>) at src/libavfilter/avfilter.c:1193
#5  ff_filter_activate (filter=<optimized out>) at src/libavfilter/avfilter.c:1352
#6  0x000000000045f2d3 in push_frame (graph=0x23cb600) at src/libavfilter/buffersrc.c:169
#7  av_buffersrc_add_frame_flags (ctx=0x23cd780, frame=<optimized out>, flags=4) at src/libavfilter/buffersrc.c:258
#8  0x0000000000429f4d in ifilter_send_frame (ifilter=<optimized out>, frame=<optimized out>, keep_reference=<optimized out>) at src/fftools/ffmpeg.c:2039
#9  send_frame_to_filters (ist=<optimized out>, decoded_frame=<optimized out>) at src/fftools/ffmpeg.c:2108
#10 0x0000000000425a2e in decode_video (ist=<optimized out>, pkt=<optimized out>, got_output=<optimized out>, duration_pts=<optimized out>, eof=<optimized out>, decode_failed=<optimized out>) at src/fftools/ffmpeg.c:2297
#11 process_input_packet (ist=<optimized out>, pkt=<optimized out>, no_eof=<optimized out>) at src/fftools/ffmpeg.c:2451
#12 0x0000000000422555 in process_input (file_index=<optimized out>) at src/fftools/ffmpeg.c:3888
#13 transcode_step () at src/fftools/ffmpeg.c:4023
#14 transcode () at src/fftools/ffmpeg.c:4074
#15 0x000000000041f526 in main (argc=<optimized out>, argv=<optimized out>) at src/fftools/ffmpeg.c:4245
(gdb) disass $pc-32,$pc+32
Dump of assembler code from 0x518a2f to 0x518a6f:
   0x0000000000518a2f <draw_region_rgb_packed+319>:     add    %cl,-0x9(%rcx,%rcx,4)
   0x0000000000518a33 <draw_region_rgb_packed+323>:     mov    %ebp,%esi
   0x0000000000518a35 <draw_region_rgb_packed+325>:     mov    %eax,%edx
   0x0000000000518a37 <draw_region_rgb_packed+327>:     callq  *0x80(%rsp)
   0x0000000000518a3e <draw_region_rgb_packed+334>:     test   %eax,%eax
   0x0000000000518a40 <draw_region_rgb_packed+336>:     je     0x518a68 <draw_region_rgb_packed+376>
   0x0000000000518a42 <draw_region_rgb_packed+338>:     movzbl 0x2c(%r14),%eax
   0x0000000000518a47 <draw_region_rgb_packed+343>:     mov    %al,(%r15)
   0x0000000000518a4a <draw_region_rgb_packed+346>:     movzbl 0x2d(%r14),%eax
=> 0x0000000000518a4f <draw_region_rgb_packed+351>:     mov    %al,(%r12)
   0x0000000000518a53 <draw_region_rgb_packed+355>:     movzbl 0x2e(%r14),%eax
   0x0000000000518a58 <draw_region_rgb_packed+360>:     mov    %al,(%rbx)
   0x0000000000518a5a <draw_region_rgb_packed+362>:     movzbl 0x2f(%r14),%eax
   0x0000000000518a5f <draw_region_rgb_packed+367>:     mov    0x8(%rsp),%rcx
   0x0000000000518a64 <draw_region_rgb_packed+372>:     mov    %al,(%rcx,%r15,1)
   0x0000000000518a68 <draw_region_rgb_packed+376>:     mov    0x10(%rsp),%rax
   0x0000000000518a6d <draw_region_rgb_packed+381>:     add    %rax,%r15
End of assembler dump.
(gdb) info register
rax            0x0      0
rbx            0x0      0
rcx            0x0      0
rdx            0x0      0
rsi            0x0      0
rdi            0x23cca40        37538368
rbp            0x0      0x0
rsp            0x7ffffffec6a0   0x7ffffffec6a0
r8             0x3      3
r9             0x0      0
r10            0xc      12
r11            0x0      0
r12            0x0      0
r13            0x0      0
r14            0x23cca40        37538368
r15            0x24a4340        38421312
rip            0x518a4f 0x518a4f <draw_region_rgb_packed+351>
eflags         0x10202  [ IF RF ]
cs             0x33     51
ss             0x2b     43
ds             0x0      0
es             0x0      0
fs             0x0      0
gs             0x0      0

comment:3 by James, 21 months ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.