[all-commits] [llvm/llvm-project] 5752e3: [lldb] fix dead lock in TypeCategoryMap.cpp (#87540)

Vincent Belliard via All-commits all-commits at lists.llvm.org
Fri Apr 12 08:17:48 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5752e3196bc52fdac70e3650abc703570ff6209b
      https://github.com/llvm/llvm-project/commit/5752e3196bc52fdac70e3650abc703570ff6209b
  Author: Vincent Belliard <81770341+v-bulle at users.noreply.github.com>
  Date:   2024-04-12 (Fri, 12 Apr 2024)

  Changed paths:
    M lldb/source/DataFormatters/TypeCategoryMap.cpp

  Log Message:
  -----------
  [lldb] fix dead lock in TypeCategoryMap.cpp (#87540)

FormatManager::GetCategoryForLanguage and
FormatManager::GetCategory(can_create = true) can be called concurrently
and they both take the TypeCategory::m_map_mutex and the
FormatManager::m_language_categories_mutex but in reverse order.

On one thread, GetCategoryForLanguage takes m_language_categories_mutex
and then ends calling TypeCategoryMap::Get which takes m_map_mutex

On another thread GetCategory calls TypeCategoryMap::Add which takes
m_map_mutex and then calls FormatManager::Changed() which takes
m_language_categories_mutex

If both threads are running concurrently, we have a dead lock.

The patch releases the m_map_mutex before calling Changed which avoids
the dead lock.

---------

Co-authored-by: Vincent Belliard <v-bulle at github.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list