Skip to content

[config] reloading configuration with not exist parent directory of log path will cause panic: runtime error: invalid memory address or nil pointer dereference #5132

@bronze1man

Description

@bronze1man

Which version are you using?

MediaMTX v1.15.3

Which operating system are you using?

Linux amd64 standard

Describe the issue

reloading configuration with not exist parent directory of log path will cause panic: runtime error: invalid memory address or nil pointer dereference .
I want it just tell me the parent directory of log path not exist. Or simple just mkdir that dir and make it work. Do not crash the process.

Describe how to replicate the issue

  1. config with logDestinations: [stdout]
  2. start the MediaMTX
  3. change the mediamtx.yml to logDestinations: [file] and logFile: /opt/mediamtx/log/mediamtx.log and /opt/mediamtx/log not exist.

MediaMTX configuration

# Verbosity of the program; available values are "error", "warn", "info", "debug".
logLevel: info
# Destinations of log messages; available values are "stdout", "file" and "syslog".
logDestinations: [file]
# If "file" is in logDestinations, this is the file which will receive the logs.
logFile: /opt/mediamtx/log/mediamtx.log

MediaMTX logs

2025/10/27 09:36:47 INF reloading configuration (file changed)
2025/10/27 09:36:47 INF [API] listener is closing
2025/10/27 09:36:47 INF [WebRTC] listener is closing
2025/10/27 09:36:47 INF [RTMP] listener is closing
2025/10/27 09:36:47 INF [RTSP] listener is closing
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xf35f60]

goroutine 13 [running]:
github.com/bluenviron/mediamtx/internal/logger.(*Logger).Log(0xc0002cbd40?, 0xc00034ac08?, {0x1646d35?, 0x0?}, {0xc00035a6a0?, 0x18b96c0?, 0xc0003afc80?})
        /s/internal/logger/logger.go:145 +0x40
github.com/bluenviron/mediamtx/internal/core.(*Core).Log(...)
        /s/internal/core/core.go:201
github.com/bluenviron/mediamtx/internal/core.(*Core).run(0xc0002cbd40)
        /s/internal/core/core.go:234 +0x3e5
created by github.com/bluenviron/mediamtx/internal/core.New in goroutine 1
        /s/internal/core/core.go:183 +0x729
ERR: open /opt/mediamtx/log/mediamtx.log: no such file or directory

Network dump

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions