Skip to content

call_center: check the online agents list under the lock in cc_timer_agents - #4536

Open
patrickcmartins wants to merge 1 commit into
OpenSIPS:masterfrom
patrickcmartins:call-center-timer-null-agent
Open

patrickcmartins wants to merge 1 commit into
OpenSIPS:masterfrom
patrickcmartins:call-center-timer-null-agent

Conversation

@patrickcmartins

Copy link
Copy Markdown

Fixes #4523

cc_timer_agents() checked data->agents[CC_AG_ONLINE] for NULL before lock_get(data->lock). If another process logged out the last online agent between the check and the lock, the do { } while loop dereferenced a NULL agent (agent->state, the SIGSEGV in the issue's backtrace).

This moves the empty-list check under the lock and releases the lock before returning. The data == NULL check stays before the lock.

This is the fix suggested in the issue. It's a small change, but I couldn't reproduce the race locally (it's timing-dependent).

…agents

The empty-list check ran before lock_get(). If the last online agent logged
out in between, the do/while loop dereferenced a NULL agent (SIGSEGV at
agent->state).

Fixes OpenSIPS#4523
@andbod

andbod commented Dec 4, 2026

Copy link
Copy Markdown

Thanks for picking this up. I reviewed the change against the core dump behind #4523 and it addresses the race we found:

  • In the dump (3.6.9, call_center.so) the segfault is the read of agent->state (offset 0x174) with agent == 0x0, inside the loop of cc_timer_agents(): the online list was non-empty at the unlocked check and empty once data->lock was taken.
  • With this patch the CC_AG_ONLINE check happens after lock_get(), so the loop can no longer start on an empty list, and the early return releases the lock.

A note for the maintainers: we run the 3.6 packages from apt.opensips.org, so a backport to the 3.6 branch would be appreciated once this is merged. Until then we keep our workaround (a technical agent that is always logged in, so the online list is never empty).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CRASH] call_center: cc_timer_agents dereferences NULL agent (empty-list check outside the lock)

2 participants