icexin opened a new issue, #3091:
URL: https://github.com/apache/brpc/issues/3091

   **Describe the bug**
   如代码所示
   
https://github.com/apache/brpc/blob/0e7c6448a4e0ecfe9926b247262fb841b87db5f8/src/bthread/task_group.cpp#L110
   `_mm_load_si128`指令需要内存16字节对齐,而 `value` 来自与栈上的一个变量,不一定满足情况。
   
   `AtomicInteger128::load` 函数也会有这个问题
   
https://github.com/apache/brpc/blob/0e7c6448a4e0ecfe9926b247262fb841b87db5f8/src/bthread/task_group.cpp#L97
 
   
   **To Reproduce**
   一个简单的dummy server,启动就会core.
   
   ``` c++
   #include <brpc/server.h>
   #include <gflags/gflags.h>
   #include <thread>
   
   int main(int argc, char* argv[]) {
       google::ParseCommandLineFlags(&argc, &argv, true);
       int ret = brpc::StartDummyServerAt(7447);
       if (ret != 0) {
           LOG(ERROR) << "Failed to start dummy server";
           return 1;
       }
       std::this_thread::sleep_for(std::chrono::seconds(1000));
       return 0;
   }
   ```
   
   **Expected behavior**
   
   
   **Versions**
   OS: ubuntu20.04
   Compiler: clang 12
   brpc: 1.14.1
   protobuf: 27.1
   
   **Additional context/screenshots**
   
   core dump stack
   ```
   Thread 7 "dummy_server" received signal SIGSEGV, Segmentation fault.
   [Switching to Thread 0x7ffff39fe700 (LWP 96948)]
   0x0000000000758aa0 in bthread::AtomicInteger128::store (this=0x7ffff03ff040, 
value=...) at external/brpc+/src/bthread/task_group.cpp:110
   110         __m128i v = _mm_load_si128(reinterpret_cast<__m128i*>(&value));
   (gdb) bt
   #0  0x0000000000758aa0 in bthread::AtomicInteger128::store 
(this=0x7ffff03ff040, value=...) at 
external/brpc+/src/bthread/task_group.cpp:110
   #1  0x000000000075e3fe in bthread::TaskGroup::AtomicCPUTimeStat::store 
(this=0x7ffff03ff040, cpu_time_stat=...) at 
external/brpc+/src/bthread/task_group.h:293
   #2  0x000000000075a163 in bthread::TaskGroup::init (this=0x7ffff03ff000, 
runqueue_capacity=4096) at external/brpc+/src/bthread/task_group.cpp:326
   #3  0x000000000076a443 in bthread::TaskControl::create_group 
(this=0x7ffff745f400, tag=0) at external/brpc+/src/bthread/task_control.cpp:133
   #4  0x0000000000769883 in bthread::TaskControl::worker_thread 
(arg=0x7ffff75fce40) at external/brpc+/src/bthread/task_control.cpp:93
   #5  0x00007ffff7f93609 in start_thread (arg=<optimized out>) at 
pthread_create.c:477
   #6  0x00007ffff7ad4353 in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:95
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to