diff options
author | Sverker Eriksson <[email protected]> | 2013-01-25 15:18:40 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2013-01-28 14:36:25 +0100 |
commit | 9d61b560f2d8a08d6cfc95dd09c0d37c1d994153 (patch) | |
tree | 685f564244597bed31fd64692719a009f466fa01 /erts/emulator | |
parent | be062ca7528b3267a6ef08653b001913fc12ae8e (diff) | |
download | otp-9d61b560f2d8a08d6cfc95dd09c0d37c1d994153.tar.gz otp-9d61b560f2d8a08d6cfc95dd09c0d37c1d994153.tar.bz2 otp-9d61b560f2d8a08d6cfc95dd09c0d37c1d994153.zip |
erts: Fix ASSERT crash in erts_try_seize_code_write_permission
ASSERT(code_writing_process != c_p);
The assert was actually harmless and could be removed as one solution.
But I think it's better to keep it as a way to catch bugs that would
otherwise lead to horrible deadlocks if a thread "forgets" to call
erts_release_code_write_permission().
As a result erts_release_code_write_permission() must be called BEFORE
resuming the suspended process.
Diffstat (limited to 'erts/emulator')
-rw-r--r-- | erts/emulator/beam/beam_bif_load.c | 8 | ||||
-rw-r--r-- | erts/emulator/beam/code_ix.h | 5 | ||||
-rw-r--r-- | erts/emulator/beam/erl_bif_trace.c | 2 |
3 files changed, 8 insertions, 7 deletions
diff --git a/erts/emulator/beam/beam_bif_load.c b/erts/emulator/beam/beam_bif_load.c index e0a4f86d2d..73264214ce 100644 --- a/erts/emulator/beam/beam_bif_load.c +++ b/erts/emulator/beam/beam_bif_load.c @@ -389,16 +389,16 @@ static void smp_code_ix_commiter(void* null) Process* p = commiter_state.stager; erts_commit_staging_code_ix(); +#ifdef DEBUG + commiter_state.stager = NULL; +#endif + erts_release_code_write_permission(); erts_smp_proc_lock(p, ERTS_PROC_LOCK_STATUS); if (!ERTS_PROC_IS_EXITING(p)) { erts_resume(p, ERTS_PROC_LOCK_STATUS); } erts_smp_proc_unlock(p, ERTS_PROC_LOCK_STATUS); erts_smp_proc_dec_refc(p); -#ifdef DEBUG - commiter_state.stager = NULL; -#endif - erts_release_code_write_permission(); } #endif /* ERTS_SMP */ diff --git a/erts/emulator/beam/code_ix.h b/erts/emulator/beam/code_ix.h index e2bd0da112..3f4f9776a4 100644 --- a/erts/emulator/beam/code_ix.h +++ b/erts/emulator/beam/code_ix.h @@ -76,7 +76,7 @@ ErtsCodeIndex erts_active_code_ix(void); /* Return staging code ix. * Only used by a process performing code loading/upgrading/deleting/purging. - * code_ix must be locked. + * Code write permission must be seized. */ ERTS_GLB_INLINE ErtsCodeIndex erts_staging_code_ix(void); @@ -84,9 +84,10 @@ ErtsCodeIndex erts_staging_code_ix(void); /* Try seize exclusive code write permission. Needed for code staging. * Main process lock (only) must be held. * System thread progress must not be blocked. + * Caller must not already hold the code write permission. * Caller is suspended and *must* yield if 0 is returned. */ -int erts_try_seize_code_write_permission(struct process*); +int erts_try_seize_code_write_permission(struct process* c_p); /* Release code write permission. * Will resume any suspended waiters. diff --git a/erts/emulator/beam/erl_bif_trace.c b/erts/emulator/beam/erl_bif_trace.c index 99a4394666..69105b8f27 100644 --- a/erts/emulator/beam/erl_bif_trace.c +++ b/erts/emulator/beam/erl_bif_trace.c @@ -386,13 +386,13 @@ static void smp_bp_finisher(void* null) #ifdef DEBUG finish_bp.stager = NULL; #endif + erts_release_code_write_permission(); erts_smp_proc_lock(p, ERTS_PROC_LOCK_STATUS); if (!ERTS_PROC_IS_EXITING(p)) { erts_resume(p, ERTS_PROC_LOCK_STATUS); } erts_smp_proc_unlock(p, ERTS_PROC_LOCK_STATUS); erts_smp_proc_dec_refc(p); - erts_release_code_write_permission(); } } #endif /* ERTS_SMP */ |