Skip to content

Commit

Permalink
Merge 'sverker/erts/jit_debug_descriptor-leak' into maint
Browse files Browse the repository at this point in the history
OTP-17445
  • Loading branch information
sverker committed May 26, 2021
2 parents f3a1966 + 3508c71 commit 045ce64
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions erts/emulator/beam/erl_lock_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ static erts_lc_lock_order_t erts_lock_order[] = {
{ "erts_alloc_hard_debug", NULL },
{ "hard_dbg_mseg", NULL },
{ "perf", NULL },
{ "jit_debug_descriptor", NULL },
{ "erts_mmap", NULL }
};

Expand Down
9 changes: 9 additions & 0 deletions erts/emulator/beam/jit/x86/beam_asm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ struct jit_descriptor {
jit_actions action_flag;
struct jit_code_entry *relevant_entry;
struct jit_code_entry *first_entry;
erts_mtx_t mutex;
};

extern "C"
Expand Down Expand Up @@ -665,6 +666,12 @@ static void beamasm_init_gdb_jit_info(void) {
__jit_debug_descriptor.first_entry = entry;
__jit_debug_descriptor.relevant_entry = entry;
__jit_debug_register_code();

erts_mtx_init(&__jit_debug_descriptor.mutex,
"jit_debug_descriptor",
NIL,
(ERTS_LOCK_FLAGS_PROPERTY_STATIC |
ERTS_LOCK_FLAGS_CATEGORY_GENERIC));
}

void BeamAssembler::update_gdb_jit_info(std::string modulename,
Expand Down Expand Up @@ -711,6 +718,7 @@ void BeamAssembler::update_gdb_jit_info(std::string modulename,
ASSERT(symfile_size == (symfile - entry->symfile_addr));

/* Insert into linked list */
erts_mtx_lock(&__jit_debug_descriptor.mutex);
entry->next_entry = __jit_debug_descriptor.first_entry;
if (entry->next_entry) {
entry->next_entry->prev_entry = entry;
Expand All @@ -723,6 +731,7 @@ void BeamAssembler::update_gdb_jit_info(std::string modulename,
__jit_debug_descriptor.first_entry = entry;
__jit_debug_descriptor.relevant_entry = entry;
__jit_debug_register_code();
erts_mtx_unlock(&__jit_debug_descriptor.mutex);
}

extern "C"
Expand Down

0 comments on commit 045ce64

Please sign in to comment.