lms icon indicating copy to clipboard operation
lms copied to clipboard

[Bug] Magick: abort due to signal 11 (SIGSEGV) "Segmentation Fault"

Open stkw0 opened this issue 11 months ago • 10 comments

In some very specific cases (I only hit this once per month or so), the LMS server crashes with a segmentation fault. This is an example of the last log:

[2025-Feb-10 08:52:01.246] 20990 - [info] - 139671583585984 [TRANSCODING] [1273] - Transcoding file '/var/lib/syncthing/Music/Number Girl/[19991216] NUMBER GIRL - シブヤROCKTRANSFORMED状態/04. 桜のダンス.mp3'
[2025-Feb-10 08:52:01.298] 20990 - [error] "Http::ResponseContinuation: WebWriteEvent::Error"
[2025-Feb-10 08:52:01.298] 20990 - [info] "WebRequest: took 779.126 ms"
[2025-Feb-10 08:52:01.533] 20990 - [error] "Http::ResponseContinuation: WebWriteEvent::Error"
[2025-Feb-10 08:52:01.534] 20990 - [info] "WebRequest: took 1020.67 ms"
Magick: abort due to signal 11 (SIGSEGV) "Segmentation Fault"...

When I tried to play again the same file with transcoding enabled I couldn't reproduce the segmentation fault.

stkw0 avatar Feb 10 '25 10:02 stkw0

Hello! Thanks for reporting! You mean this crashes only on files that are transcoded? What package/distrib are you using? (Lms is using STB by default, not graphicsmagick)

epoupon avatar Feb 10 '25 13:02 epoupon

I only observed this crash 2 times in the last months, so I don't have that much info right now. The two crashes happened with transcoded files.

I'm using Gentoo and I am also who is maintaining the package of LMS. I don't know why I thought STB was an alternative to graphicsmagic (in the sense the later was the default one). I would change it for next release.

If I can gather more information I will add it to this issue. For now I thought even if I don't have much to properly diagnose the issue could be helpful in case other issues hits the same isue.

stkw0 avatar Feb 10 '25 14:02 stkw0

Can you try to set the log level to debug? Set in in lms.conf: log-min-severity = "info";

I do have branch that appends more information if a crash occurs (like a callstack), but unfortunately the sig handler set by magick is likely to make it useless... It also requires to compile LMS with a special option and to keep the debug symbols.

epoupon avatar Feb 10 '25 15:02 epoupon

I changed the log level to "debug" and also switched to stb instead of Magick, today LMS crashed, the loks show the next message

[2025-Mar-16 06:32:03.857] 2850 - [debug] - 140473893095104 [API_SUBSONIC] Handling request 10515 '/stream.view', continuation = true, params = {c=Symfonium}, {f=json}, {id=tr-8594}, {p=*REDACTED*}, {u=david}, {v=1.13.0},
[2025-Mar-16 06:32:03.857] 2850 - [debug] - 140473893095104 [TRANSCODING] Transcoder finished = 0, total served bytes = 2097152, mime type = audio/mpeg
[2025-Mar-16 06:32:03.857] 2850 - [debug] - 140473893095104 [TRANSCODING] Writing 262144 bytes back to client
[2025-Mar-16 06:32:03.857] 2850 - [debug] - 140473893095104 [CHILDPROC] Async read, bufferSize = 262144
[2025-Mar-16 06:32:03.857] 2850 - [debug] - 140473893095104 [API_SUBSONIC] Request 10515 '/stream' handled!
[2025-Mar-16 06:32:03.857] 2850 - [error] "Http::ResponseContinuation: WebWriteEvent::Error"
[2025-Mar-16 06:32:03.857] 2850 - [info] "WebRequest: took 953.548 ms"
[2025-Mar-16 06:32:03.857] 2850 - [debug] - 140474054596288 [CHILDPROC] Closing child process...
[2025-Mar-16 06:32:03.857] 2850 - [debug] - 140474054596288 [CHILDPROC] Killing child process...

There is the same WebWriteEvent::Error but I'm surprised that LMS seems to catch the error and instead of trying to recover it seems to shutdown¿?

stkw0 avatar Mar 17 '25 10:03 stkw0

Hmmm interesting! Will add some internal debug facilities to have a better idea of what is wrong, will tell you when ready

epoupon avatar Mar 17 '25 10:03 epoupon

As of today, with version 3.65.0, I still get the same error from time to time. After the crash, I don't see any new debug messages. It's strange that it happens so sporadically.

Last log:

[2025-Apr-17 08:52:33.042] 26717 - [debug] - 140201531786944 [API_SUBSONIC] Handling request 60160 '/stream.view', continuation = true, params = {c=Symfonium}, {f=json}, {id=tr-4662}, {p=*REDACTED*}, {u=david}, {v=1.13.0},
[2025-Apr-17 08:52:33.042] 26717 - [debug] - 140201531786944 [TRANSCODING] Transcoder finished = 0, total served bytes = 0, mime type = audio/mpeg
[2025-Apr-17 08:52:33.042] 26717 - [debug] - 140201531786944 [TRANSCODING] Writing 262144 bytes back to client
[2025-Apr-17 08:52:33.043] 26717 - [debug] - 140201531786944 [CHILDPROC] Async read, bufferSize = 262144
[2025-Apr-17 08:52:33.043] 26717 - [debug] - 140201531786944 [API_SUBSONIC] Request 60160 '/stream' handled!
[2025-Apr-17 08:52:33.114] 26717 - [debug] - 140201523394240 [CHILDPROC] Async read cb - ec = 'Success' (0), bytesTransferred = 262144
[2025-Apr-17 08:52:33.114] 26717 - [debug] - 140201523394240 [TRANSCODING] Have 262144 more bytes to send back
[2025-Apr-17 08:52:33.114] 26717 - [debug] - 140201523394240 [API_SUBSONIC] Handling request 60161 '/stream.view', continuation = true, params = {c=Symfonium}, {f=json}, {format=mp3}, {id=tr-16154}, {maxBitRate=256}, {p=*REDACTED*}, {u=david}, {v=1.13.0},
[2025-Apr-17 08:52:33.114] 26717 - [debug] - 140201523394240 [TRANSCODING] Transcoder finished = 0, total served bytes = 262144, mime type = audio/mpeg
[2025-Apr-17 08:52:33.115] 26717 - [debug] - 140201523394240 [TRANSCODING] Writing 262144 bytes back to client
[2025-Apr-17 08:52:33.115] 26717 - [debug] - 140201523394240 [CHILDPROC] Async read, bufferSize = 262144
[2025-Apr-17 08:52:33.115] 26717 - [debug] - 140201523394240 [API_SUBSONIC] Request 60161 '/stream' handled!
[2025-Apr-17 08:52:33.115] 26717 - [error] "Http::ResponseContinuation: WebWriteEvent::Error"
[2025-Apr-17 08:52:33.115] 26717 - [info] "WebRequest: took 381.093 ms"
[2025-Apr-17 08:52:33.115] 26717 - [debug] - 140201670198976 [CHILDPROC] Closing child process...
[2025-Apr-17 08:52:33.115] 26717 - [debug] - 140201670198976 [CHILDPROC] Killing child process...

stkw0 avatar Apr 18 '25 12:04 stkw0

Hello! Thanks for the update. Indeed I didn't add any crash analysis yet , will do!

epoupon avatar Apr 19 '25 15:04 epoupon

Using version 3.69.0 I noticed the crash with the message: Magick: abort due to signal 11 (SIGSEGV) "Segmentation Fault"... but I found it curious since it was using STB (it showed Using stb (resize version 2) when compiling)

stkw0 avatar Sep 02 '25 09:09 stkw0

Ah then maybe this is because Wt is built using magick support. Could you check using ldd on wt libraries?

epoupon avatar Sep 02 '25 17:09 epoupon

Yeah, that seems to be the case

stkw0 avatar Sep 02 '25 17:09 stkw0