[Lldb-commits] [lldb] Fix lldb crash while handling concurrent vfork() (PR #81564)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Feb 12 18:11:41 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff bc66e0cf9feb8f3c38fa2e33850b6c6e5477fb21 d65900f5e6169062fc0988b57fb5be2474789025 -- lldb/test/API/functionalities/fork/concurrent_vfork/main.cpp lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 8ab2257e0a..6fdb062e71 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -263,8 +263,7 @@ ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp,
m_continue_C_tids(), m_continue_s_tids(), m_continue_S_tids(),
m_max_memory_size(0), m_remote_stub_max_memory_size(0),
m_addr_to_mmap_size(), m_thread_create_bp_sp(),
- m_waiting_for_attach(false),
- m_command_sp(), m_breakpoint_pc_offset(0),
+ m_waiting_for_attach(false), m_command_sp(), m_breakpoint_pc_offset(0),
m_initial_tid(LLDB_INVALID_THREAD_ID), m_allow_flash_writes(false),
m_erased_flash_ranges(), m_vfork_in_progress(0) {
m_async_broadcaster.SetEventName(eBroadcastBitAsyncThreadShouldExit,
diff --git a/lldb/test/API/functionalities/fork/concurrent_vfork/main.cpp b/lldb/test/API/functionalities/fork/concurrent_vfork/main.cpp
index 1bb225b1ca..1b75852c31 100644
--- a/lldb/test/API/functionalities/fork/concurrent_vfork/main.cpp
+++ b/lldb/test/API/functionalities/fork/concurrent_vfork/main.cpp
@@ -1,6 +1,6 @@
+#include <iostream>
#include <thread>
#include <unistd.h>
-#include <iostream>
#include <vector>
int call_vfork() {
@@ -9,33 +9,32 @@ int call_vfork() {
pid_t child_pid = vfork();
if (child_pid == -1) {
- // Error handling
- perror("vfork");
- return 1;
+ // Error handling
+ perror("vfork");
+ return 1;
} else if (child_pid == 0) {
- // This code is executed by the child process
- printf("Child process\n");
- _exit(0); // Exit the child process
+ // This code is executed by the child process
+ printf("Child process\n");
+ _exit(0); // Exit the child process
} else {
- // This code is executed by the parent process
- printf("Parent process\n");
+ // This code is executed by the parent process
+ printf("Parent process\n");
}
printf("After vfork\n");
return 0;
}
-void worker_thread() {
- call_vfork();
-}
+void worker_thread() { call_vfork(); }
void create_threads(int num_threads) {
std::vector<std::thread> threads;
for (int i = 0; i < num_threads; ++i) {
threads.emplace_back(std::thread(worker_thread));
}
- printf("Created %d threads, joining...\n", num_threads); // end_of_create_threads
- for (auto &thread: threads) {
+ printf("Created %d threads, joining...\n",
+ num_threads); // end_of_create_threads
+ for (auto &thread : threads) {
thread.join();
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/81564
More information about the lldb-commits
mailing list