aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2013-08-27 12:24:30 +0200
committerLukas Larsson <[email protected]>2013-08-27 12:24:30 +0200
commitb368fb879676fa6dd2d251ba6583d0a86d04aeb0 (patch)
tree013939e431efa53b341032590ec2c2dcd9063331 /erts/emulator/beam
parente2c0f6dd1fc9b6bd506a481644b9c63f9d575aa1 (diff)
downloadotp-b368fb879676fa6dd2d251ba6583d0a86d04aeb0.tar.gz
otp-b368fb879676fa6dd2d251ba6583d0a86d04aeb0.tar.bz2
otp-b368fb879676fa6dd2d251ba6583d0a86d04aeb0.zip
erts: Fix segfault when scheduling release_port later_op
begin_port_cleanup can be called from a non-scheduler thread, this means that there is no esdp available and thus erts_schedule_thr_prgr_later_op segfaults.
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r--erts/emulator/beam/erl_port_task.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/erts/emulator/beam/erl_port_task.c b/erts/emulator/beam/erl_port_task.c
index 7d53ce7152..547a42beb2 100644
--- a/erts/emulator/beam/erl_port_task.c
+++ b/erts/emulator/beam/erl_port_task.c
@@ -1838,6 +1838,16 @@ release_port(void *vport)
{
erts_port_dec_refc((Port *) vport);
}
+
+static void
+schedule_release_port(void *vport) {
+ Port *pp = (Port*)vport;
+ /* This is only used when a port release was ordered from a non-scheduler */
+ erts_schedule_thr_prgr_later_op(release_port,
+ (void *) pp,
+ &pp->common.u.release);
+}
+
#endif
static void
@@ -2033,10 +2043,15 @@ begin_port_cleanup(Port *pp, ErtsPortTask **execqp, int *processing_busy_q_p)
* Schedule cleanup of port structure...
*/
#ifdef ERTS_SMP
- /* Has to be more or less immediate to release any driver */
- erts_schedule_thr_prgr_later_op(release_port,
- (void *) pp,
- &pp->common.u.release);
+ /* We might not be a scheduler, eg. traceing to port we are sys_msg_dispatcher */
+ if (!erts_get_scheduler_data()) {
+ erts_schedule_misc_aux_work(1, schedule_release_port, (void*)pp);
+ } else {
+ /* Has to be more or less immediate to release any driver */
+ erts_schedule_thr_prgr_later_op(release_port,
+ (void *) pp,
+ &pp->common.u.release);
+ }
#else
pp->cleanup = 1;
#endif