CasparCG / server

CasparCG Server is a Windows and Linux software used to play out professional graphics, audio and video to multiple outputs. It has been in 24/7 broadcast production since 2006. Ready-to-use downloads are available under the Releases tab https://casparcg.com.
GNU General Public License v3.0
905 stars 268 forks source link

Bug: Server does not exit gracefully #1571

Open dimitry-ishenko opened 1 week ago

dimitry-ishenko commented 1 week ago

Observed Behavior

For example, starting server in an empty directory (without casparcg.config), I get this:

dimitry@laptop:~/tmp$ casparcg 
Type "q" to close application.
Aborted

If there is an earlier backtrace in the directory, I will get this:

dimitry@laptop:~/tmp$ casparcg 
[2024-09-19 23:12:11.593643] [0x000079c055fba700] [error]    0# 0x00005D8FCAB0C9B4
 1# 0x0000708F77A45320
 2# 0x0000708F77A9EB1C
 3# 0x0000708F77A4526E
 4# 0x0000708F77A45320
 5# 0x00005D8FCAB850BC
 6# 0x00005D8FCAB80955
 7# 0x00005D8FCAB85E25
 8# 0x0000708F86CD797F
 9# 0x0000708F77A9CA94
10# 0x0000708F77B29C3C

Type "q" to close application.
Aborted

If the config file is corrupt, I may get one of these:

dimitry@laptop:~/tmp/casparcg$ casparcg-server-2.4 
Type "q" to close application.
dimitry@laptop:~/tmp/casparcg$ casparcg-server-2.4 
Type "q" to close application.
Aborted
dimitry@laptop:~/tmp/casparcg$ casparcg-server-2.4 
[2024-09-19 23:15:11.469021] [0x000070382a705700] [error]    0# 0x000059878C21D9B4
 1# 0x000071F27B845320
 2# 0x000071F27B89EB1C
 3# 0x000071F27B84526E
 4# 0x000071F27B845320
 5# 0x000059878C2960BC
 6# 0x000059878C291955
 7# 0x000059878C296E25
 8# 0x000071F28C19A97F
 9# 0x000071F27B89CA94
10# 0x000071F27B929C3C

Type "q" to close application.

Similar thing happens if I try to launch it with, eg casparcg -h or casparcg --help or any other invalid path to the config file.

Expected behaviour

Looking at the code, I should be getting an error message:

 ### Invalid configuration file. ###

But, I don't. Running in Debug mode, it seems to abort on this line:

https://github.com/CasparCG/server/blob/804b8deb339761856c3eceff5f908e148e35242d/src/common/log.cpp#L152

There appears to be some sort of a race condition, because if I step through the code it does sometimes display the message...

Steps to reproduce

See above.

Environment

alevecchio commented 1 week ago

I have a similar exit when I try to start CasparCG without a mounted drive. I didn't check the error code to see if is the same. Config file is ok, but the media drive "is not there".

dimitry-ishenko commented 1 week ago

I have a similar exit when I try to start CasparCG without a mounted drive. I didn't check the error code to see if is the same. Config file is ok, but the media drive "is not there".

I suspect it's the same problem. The server tried to access the media path, an exception gets thrown and it aborts during logging.

dimitry-ishenko commented 1 week ago

Just confirmed that if I set media path to a non-existent directory and the server doesn't have write access to create it, it will fail in the same way.