Melt segfaults in swscaler and lots of spam, cannot export video

I spent a few weekends editing footage together in Kdenlive, but now I can’t export it.

Exporting only a few minutes works. Exporting even 15 minutes of it leads to melt-7 segfaulting partway through. It doesn’t seem to emit any useful messages other than lots of:
[swscaler @ 0x7ffdfc000900] deprecated pixel format used, make sure you did set range correctly

I built a debug copy of upstream melt and tried to use that on a kdenlive exported script:


[swscaler @ 0x7ffe24000900] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ffe0c000900] deprecated pixel format used, make sure you did set range correctly
[aac @ 0x7ffed028f080] Input contains (near) NaN/+-Inf
[consumer avformat] error with audio encode: -22 (frame 8786)
[swscaler @ 0x7ffe24000900] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ffe04000900] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ffe2c000900] deprecated pixel format used, make sure you did set range correctly
[aac @ 0x7ffed028f080] Input contains (near) NaN/+-Inf
[consumer avformat] error with audio encode: -22 (frame 8788)
[swscaler @ 0x7ffe1c000900] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ffe2c000900] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ffe0c000900] deprecated pixel format used, make sure you did set range correctly
[aac @ 0x7ffed028f080] Input contains (near) NaN/+-Inf
[consumer avformat] error with audio encode: -22 (frame 8789)
[swscaler @ 0x7ffe00000900] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ffe2c000900] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ffe0c000900] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ffe2c000900] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ffe0c000900] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ffe08000900] deprecated pixel format used, make sure you did set range correctly
[aac @ 0x7ffed028f080] Input contains (near) NaN/+-Inf
[consumer avformat] error with audio encode: -22 (frame 8790)
[swscaler @ 0x7ffe0c000900] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ffe00000900] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ffdf4000900] deprecated pixel format used, make sure you did set range correctly
Current Position:       8789
Thread 53 "melt" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffed567b6c0 (LWP 2702)]
0x00007fffb012717f in ?? () from /usr/lib/libswscale.so.5
(gdb) bt
#0  0x00007fffb012717f in ?? () from /usr/lib/libswscale.so.5
#1  0x00007fffb01272e6 in ?? () from /usr/lib/libswscale.so.5
#2  0x00007fffb011367c in ?? () from /usr/lib/libswscale.so.5
#3  0x00007fffb010650b in sws_scale () from /usr/lib/libswscale.so.5
#4  0x00007fffb01a6028 in encode_video (enc_ctx=0x7ffed0000b80, converted_avframe=0x7ffed27f9200, 
    video_outbuf=0x7ffecbfff040 "", video_outbuf_size=67108864, frame=0x7ffed13158f0, 
    img_fmt=mlt_image_yuv422)
    at /home/valentine/scratch/mlt/src/modules/avformat/consumer_avformat.c:1787
#5  0x00007fffb01a8843 in consumer_thread (arg=0x5555cbb8ca00)
    at /home/valentine/scratch/mlt/src/modules/avformat/consumer_avformat.c:2511
#6  0x00007ffff7bfe579 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:448
#7  0x00007ffff7c78858 in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
(gdb) 

Any tips for what to do from here? Is there a way I can rule out swscaler being the cause (is it something optional that I can temporarily turn off as a test & re-run melt?).

My computer died a few days ago (wouldn’t POST, wouldn’t even flip PS_ON on the power connector) and the fix was to clean some wet fuzzy dust next to a slightly corroded crystal on the motherboard. The system now passes memtest and mprime, but I am still worried this could be a hardware instability issue, so any thoughts on testing that would also be appreciated.

It looks like I was reading the backtrace upside down: the crash is occurring in /lib/libswscale.so, not in pthreads. I will temporarily swapout this library with a copy from another distro to see if it’s an issue with the copy my distro (Void Linux) distributes.

Possible hint: this time it crashed in code that could be related to vst2 plugins. I wonder if the vst effect I’m using to normalise voice audio levels (“GOTT Compressor L/R”) is causing memory corruption or crashes? That could also explain why kdenlive itself has become buggier and crashed more often as I edited up this sequence, especially after I deleted an audio track from the whole project.

Thread 53 "melt-7" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffe6c4e56c0 (LWP 8883)]
_dl_close (_map=0x0) at ./elf/dl-close.c:772
warning: 772	./elf/dl-close.c: No such file or directory
(gdb) bt
#0  _dl_close (_map=0x0) at ./elf/dl-close.c:772
#1  0x00007ffff7fca379 in __GI__dl_catch_exception (exception=exception@entry=0x7ffe6c4e2de0, 
    operate=0x7ffff7fcb3b0 <_dl_close>, args=0x0) at ./elf/dl-catch.c:241
#2  0x00007ffff7fca49f in _dl_catch_error (objname=0x7ffe6c4e2e38, errstring=0x7ffe6c4e2e40, 
    mallocedp=0x7ffe6c4e2e37, operate=<optimized out>, args=<optimized out>) at ./elf/dl-catch.c:260
#3  0x00007ffff7c02877 in _dlerror_run (operate=<optimized out>, args=<optimized out>) at ./dlfcn/dlerror.c:138
#4  0x00007ffff7c025a6 in __dlclose (handle=<optimized out>) at ./dlfcn/dlclose.c:31
#5  0x00007fffeeff5fca in vst2_context_destroy () from /usr/lib64/mlt-7/libmltjackrack.so
#6  0x00007ffff7f7c538 in ?? () from /usr/lib/libmlt-7.so.7
#7  0x00007ffff7f7df09 in mlt_property_close () from /usr/lib/libmlt-7.so.7
#8  0x00007ffff7f76751 in mlt_properties_close () from /usr/lib/libmlt-7.so.7
#9  0x00007ffff7f698f8 in mlt_filter_close () from /usr/lib/libmlt-7.so.7
#10 0x00007ffff7f81f51 in mlt_service_detach () from /usr/lib/libmlt-7.so.7
#11 0x00007ffff7f81ff0 in mlt_service_close () from /usr/lib/libmlt-7.so.7
#12 0x00007ffff7f73e3a in mlt_producer_close () from /usr/lib/libmlt-7.so.7
#13 0x00007ffff7f70d10 in ?? () from /usr/lib/libmlt-7.so.7
#14 0x00007ffff7f74c6d in ?? () from /usr/lib/libmlt-7.so.7
#15 0x00007ffff7f81b88 in mlt_service_get_frame () from /usr/lib/libmlt-7.so.7
#16 0x00007ffff7f6ece5 in ?? () from /usr/lib/libmlt-7.so.7
#17 0x00007ffff7f74c6d in ?? () from /usr/lib/libmlt-7.so.7
#18 0x00007ffff7f81b88 in mlt_service_get_frame () from /usr/lib/libmlt-7.so.7
#19 0x00007ffff7f8372a in ?? () from /usr/lib/libmlt-7.so.7
#20 0x00007ffff7f74c6d in ?? () from /usr/lib/libmlt-7.so.7
#21 0x00007ffff7f81b88 in mlt_service_get_frame () from /usr/lib/libmlt-7.so.7
#22 0x00007ffff7f6ece5 in ?? () from /usr/lib/libmlt-7.so.7
#23 0x00007ffff7f74c6d in ?? () from /usr/lib/libmlt-7.so.7
#24 0x00007ffff7f81b88 in mlt_service_get_frame () from /usr/lib/libmlt-7.so.7
#25 0x00007ffff7f84a3d in ?? () from /usr/lib/libmlt-7.so.7
#26 0x00007ffff7f81b88 in mlt_service_get_frame () from /usr/lib/libmlt-7.so.7
#27 0x00007ffff7f84a3d in ?? () from /usr/lib/libmlt-7.so.7
#28 0x00007ffff7f81b88 in mlt_service_get_frame () from /usr/lib/libmlt-7.so.7

Resolved!

I removed the VST plugin (uninstalled it), re-opened kdenlive and now my project renders without any errors.

I do not know if it is the plugin itself or the way that it is used that is causing the problem, so I’m hesitant to blame the compressor itself.

TL;DR do NOT touch these, they are total poison:

I’ve probably been a bit too negative there.

The GOTT compressor is really nice and this is a shame. Thankyou to the devs of these plugins and their integration into melt/kdenlive. Memory corruption issues like this are not easy to fix.

I don’t know who to report this to, it could even be a distro-specific bug from compiler flags, a GOTT bug, a melt bug, a swscaler bug or something else. It also requires quite a lot of time per render/encode to trigger and is unreliable.

Well this:

[aac @ 0x7ffed028f080] Input contains (near) NaN/+-Inf
[consumer avformat] error with audio encode: -22 (frame 8788)

Seems to indicate something in the audio chain is creating denormals and a somehow ‘invalid’ stream. Which is a bit smokey-gun shaped. And not something I’ve ever seen or seen reported here before.

The swscale warnings about pixel format are more red-herring shaped and usually harmless (for now).

And if you’ve got known hardware trouble, all bets could be off anyway.

You’re a lot of evidence short of blaming the “compiler flags” bogeyman - but only some actual debugging will tell you more about what’s really happening here.

[aac @ 0x7ffed028f080] Input contains (near) NaN/+-Inf
Seems to indicate something in the audio chain is creating denormals and a somehow ‘invalid’ stream

This message has gone. I only saw it when using an upstream (bleeding edge) copy of melt, if I use the version my distro packs then the NaN warning never appears.

(I wanted to add this extra info when I spotted I had missed adding it, but I didn’t have post edit rights at the time, apologies)

And if you’ve got known hardware trouble, all bets could be off anyway.

It now looks unlikely to be a hardware issue. Removing this audio filter reliably fixes the problem. Additionally some CPU/memory stress tests I have run for a few hours have hit no issues.

“compiler flags” bogeyman

This isn’t from nowhere, a couple of issues I’ve reported on my distro’s bugtracker have turned out to be because of this. They have their own extra hardening & stack flags that sometimes cause things to trip up.