Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[bug]: chan_console: Deadlock when hanging up console channels #308

Description

@InterLinked1

Severity

Major

Versions

20.4.0

Components/Modules

chan_console

Operating Environment

N/A

Frequency of Occurrence

Constant

Issue Description

Imported from JIRA: https://issues-archive.asterisk.org/ASTERISK-30481

chan_console deadlocks when channels are hung up, due to the read thread being cancelled while it is holding locks.

This redoes the disconnection more cleanly to avoid using pthread_cancel and uncleanly terminating threads.

Relevant log output

[2023-09-09 10:59:45.148] WARNING[210230]: chan_console.c:621 console_write: before write lock
[2023-09-09 10:59:45.174] WARNING[210231]: chan_console.c:286 stream_monitor: done read lock
[2023-09-09 10:59:45.174] WARNING[210230]: chan_console.c:623 console_write: got write lock
[2023-09-09 10:59:45.174] WARNING[210230]: chan_console.c:626 console_write: done write lock
[2023-09-09 10:59:45.174] WARNING[210230]: chan_console.c:621 console_write: before write lock
[2023-09-09 10:59:45.174] WARNING[210230]: chan_console.c:623 console_write: got write lock
[2023-09-09 10:59:45.175] WARNING[210230]: chan_console.c:626 console_write: done write lock
[2023-09-09 10:59:45.175] WARNING[210231]: chan_console.c:281 stream_monitor: before read lock
[2023-09-09 10:59:45.175] WARNING[210231]: chan_console.c:283 stream_monitor: got read lock
[2023-09-09 10:59:45.175] WARNING[210231]: chan_console.c:286 stream_monitor: done read lock
[2023-09-09 10:59:45.175] WARNING[210231]: chan_console.c:281 stream_monitor: before read lock
[2023-09-09 10:59:45.175] WARNING[210231]: chan_console.c:283 stream_monitor: got read lock
[2023-09-09 10:59:45.188] WARNING[210230]: chan_console.c:621 console_write: before write lock
debian*CLI> channel request hangup all
Requested Hangup on channel 'Console/default'
[2023-09-09 10:59:45.217] WARNING[210231]: chan_console.c:286 stream_monitor: done read lock
[2023-09-09 10:59:45.217] WARNING[210230]: chan_console.c:623 console_write: got write lock
[2023-09-09 10:59:45.217] WARNING[210230]: chan_console.c:626 console_write: done write lock
[2023-09-09 10:59:45.217] WARNING[210231]: chan_console.c:281 stream_monitor: before read lock
[2023-09-09 10:59:45.217] WARNING[210231]: chan_console.c:283 stream_monitor: got read lock
[2023-09-09 10:59:45.217] WARNING[210231]: chan_console.c:286 stream_monitor: done read lock
[2023-09-09 10:59:45.218] WARNING[210231]: chan_console.c:281 stream_monitor: before read lock
[2023-09-09 10:59:45.218] WARNING[210231]: chan_console.c:283 stream_monitor: got read lock <-- LOCKED
[2023-09-09 10:59:45.218]   --- <("<) --- Hangup on Console --- (>")> ---
[2023-09-09 10:59:45.218] WARNING[210230]: chan_console.c:409 stop_stream: Killing thread <-- KILLED WHILE HOLDING LOCK
[2023-09-09 10:59:45.218] WARNING[210230]: chan_console.c:414 stop_stream: stop stream, waiting to acquire lock

Asterisk Issue Guidelines

  • Yes, I have read the Asterisk Issue Guidelines

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions