Skip to content

Conversation

@nanangizz
Copy link
Member

Registration retry acquires the PJSUA lock followed by the transport manager lock, whereas IP change acquires them in the reverse order.

Call stack trace

IP change:

pj_mutex_lock + 136
PJSUA_LOCK + 28
pjsua_acc_on_tp_state_changed + 112
on_tp_state_callback + 140
pjsip_transport_shutdown2 + 308
pjsip_tpmgr_shutdown_all + 312
pjsua_handle_ip_change + 604
pj::Endpoint::handleIpChange + 64

Registration retry:

pj_mutex_lock + 136
pj_lock_acquire + 116
pjsip_tpmgr_acquire_transport2 + 60
pjsip_endpt_acquire_transport2 + 72
pjsua_acc_get_uac_addr + 2076
pjsua_acc_create_uac_contact + 244
pjsua_regc_init + 384
pjsua_acc_set_registration + 564
auto_rereg_timer_cb + 496
pj_timer_heap_poll + 640
pjsip_endpt_handle_events2 + 92
pjsua_handle_events + 72
worker_thread + 44
thread_main + 188

Thanks to Yeuda for the report.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a deadlock that occurs when registration retry and IP change handling are triggered simultaneously due to inconsistent lock ordering between the two code paths.

Key Changes:

  • Adds PJSUA lock acquisition before calling pjsip_tpmgr_shutdown_all() in IP change handling
  • Ensures consistent lock ordering: PJSUA lock → transport manager lock

@nanangizz nanangizz merged commit 50b4164 into master Nov 25, 2025
62 of 63 checks passed
@nanangizz nanangizz deleted the deadlock-pjsua-tp branch November 25, 2025 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants