[OpenSIPS-Devel] [OpenSIPS/opensips] 531fe5: core: do not crash setting the log level before th...

Bogdan Andrei IANCU noreply at github.com
Thu Sep 3 12:22:53 UTC 2026


  Branch: refs/heads/master
  Home:   https://github.com/OpenSIPS/opensips
  Commit: 531fe59e3d8a75f9b19379a6abdf2768c345de28
      https://github.com/OpenSIPS/opensips/commit/531fe59e3d8a75f9b19379a6abdf2768c345de28
  Author: Yury Kirsanov <yury at kfi.net.au>
  Date:   2026-07-25 (Sat, 25 Jul 2026)

  Changed paths:
    M dprint.c

  Log Message:
  -----------
  core: do not crash setting the log level before the process table exists

set_proc_log_level() and reset_proc_log_level() segfault when called
from a module's mod_init(). init_modules() runs several steps before
init_multi_proc_support(), so pt is still NULL, and __set_proc_log_level()
writes pt[proc_idx].log_level unconditionally. reset_proc_log_level()
fails the same way one level down: default_log_level is a static pointer
that init_log_level() has not filled in yet, so it dereferences NULL.

This is easy to hit. Temporarily lowering the log level around a call
that is expected to fail is the natural way for a module to keep an
expected error out of its startup output, and the API gives no hint that
it is unusable at the point most modules would reach for it.

Guards each of the affected setters. Where the intent can still be
honoured it is, rather than silently dropping the request: log_level
already points at the static holder before init_log_level() runs, and
there is only one process at that stage, so __set_proc_log_level() sets
the level through it and reset_proc_log_level() restores the value
logging started with. __set_proc_default_log_level() updates that same
holder. set_global_log_level() additionally guards log_level_global,
which init_log_level() allocates - before that, counted_max_processes is
0 so its loop is a no-op and the shared value does not exist yet, so it
applies the level to the current process instead.
suppress_proc_log_event() and reset_proc_log_event() return early: the
event consumer they guard is not running yet either.

Verified by calling set_proc_log_level() followed by
reset_proc_log_level() from a module mod_init(): the same module
segfaults on an unpatched core and starts normally on a patched one.


  Commit: 33f6bdf2e2214f7162be8d01ec7372fe52219515
      https://github.com/OpenSIPS/opensips/commit/33f6bdf2e2214f7162be8d01ec7372fe52219515
  Author: Bogdan Andrei IANCU <bogdan at opensips.org>
  Date:   2026-09-03 (Thu, 03 Sep 2026)

  Changed paths:
    M dprint.c

  Log Message:
  -----------
  Merge pull request #4121 from Lt-Flash/fix/log-level-before-fork

core: do not crash setting the log level before the process table exists


Compare: https://github.com/OpenSIPS/opensips/compare/55f63f992709...33f6bdf2e221

To unsubscribe from these emails, change your notification settings at https://github.com/OpenSIPS/opensips/settings/notifications



More information about the Devel mailing list