Re: [PR] fix compiler optimize thread local variable access (brpc)

2024-05-22 Thread via GitHub
zcfh commented on PR #2156: URL: https://github.com/apache/brpc/pull/2156#issuecomment-2124600518 > 另外还有一个疑问是,函数 task_runner 和 tls_task_group 不都是在一个编译单元内吗?为什么是开启lto后才会触发这个问题呢。 这个差异找到了。和clang对tls变量访问的选择有关。如果使用-fPIC编译 + 分布式 thinlto

Re: [PR] fix compiler optimize thread local variable access (brpc)

2024-03-04 Thread via GitHub
zcfh commented on PR #2156: URL: https://github.com/apache/brpc/pull/2156#issuecomment-1976430923 目前从clang11 切换 到clang16 遇到了一些新的问题。和 #1776 提到的问题应该是一样的,不过我看**1776对应的代码并没有合入**, 是有做了其他修复吗。 对比了汇编,这样差异在于326-331 行这段代码(version 0.96) ```c++ // Clean tls variables, must be done

Re: [PR] fix compiler optimize thread local variable access (brpc)

2024-02-05 Thread via GitHub
ehds commented on PR #2156: URL: https://github.com/apache/brpc/pull/2156#issuecomment-1926722893 > 另外还有一个疑问是,函数 task_runner 和 tls_task_group 不都是在一个编译单元内吗?为什么是开启lto后才会触发这个问题呢。 不开启 `lto` 也是会有这个问题的,具体跟编译器的类别、版本以及编译参数等有关。具体的话可以通过 llvm-objdump/objdump 工具把可执行的产物 dump 出来,看下 task_runner

Re: [PR] fix compiler optimize thread local variable access (brpc)

2024-02-04 Thread via GitHub
zcfh commented on PR #2156: URL: https://github.com/apache/brpc/pull/2156#issuecomment-1926332705 另外还有一个疑问是,函数 task_runner 和 tls_task_group 不都是在一个编译单元内吗?为什么是开启lto后才会触发这个问题呢。 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and

Re: [PR] fix compiler optimize thread local variable access (brpc)

2024-02-04 Thread via GitHub
ehds commented on PR #2156: URL: https://github.com/apache/brpc/pull/2156#issuecomment-1926276260 > 感觉还是 thread_local 读写的问题, 请问下除了这个patch外,后面还有其他关于这个问题的修复吗? 目前去掉 `src/bthread/task_group.cpp` 的lto后,可以正常工作。 > > task_runner 循环外的 tls,也加上 BAIDU_GET_VOLATILE_THREAD_LOCAL,后似乎问题不再出现了。 >

Re: [PR] fix compiler optimize thread local variable access (brpc)

2024-02-04 Thread via GitHub
zcfh commented on PR #2156: URL: https://github.com/apache/brpc/pull/2156#issuecomment-1926165119 感觉还是 thread_local 读写的问题, 请问下除了这个patch外,后面还有其他关于这个问题的修复吗? 目前去掉 `src/bthread/task_group.cpp` 的lto后,可以正常工作。 -- This is an automated message from the Apache Git Service. To respond to the

Re: [PR] fix compiler optimize thread local variable access (brpc)

2024-02-04 Thread via GitHub
zcfh commented on PR #2156: URL: https://github.com/apache/brpc/pull/2156#issuecomment-1925685544 目前还没无法构造一个最小示例。 在加上这个commit的修改后,AddressSanitizer 会提示 heap-use-after-free,不过不会显示释放的位置, 使用 `--usercode_in_pthread` 就无法复现这个错误了。 ``` ==31802==ERROR: AddressSanitizer: heap-use-after-free

Re: [PR] fix compiler optimize thread local variable access (brpc)

2024-02-04 Thread via GitHub
zcfh commented on PR #2156: URL: https://github.com/apache/brpc/pull/2156#issuecomment-1925685023 目前还没无法构造一个最小示例。 在加上这个commit的修改后,AddressSanitizer 会提示 heap-use-after-free,不过不会显示释放的位置, 使用 `--usercode_in_pthread` 就无法复现这个错误了。 ``` ==31802==ERROR: AddressSanitizer: heap-use-after-free

Re: [PR] fix compiler optimize thread local variable access (brpc)

2024-02-02 Thread via GitHub
ehds commented on PR #2156: URL: https://github.com/apache/brpc/pull/2156#issuecomment-1923713768 > > > 加上这个patch后,稳定出现第一种错误,是 socket.cpp 也有类似的问题吗? > > > > > > 是在哪个平台上出现呢?arm 还是 x86 ? 可以贴下 PoC 代码。 > > x86, `(defined(__aarch64__) || defined(__arm64__))`,去掉后不再core在前面提到的两个位置。

Re: [PR] fix compiler optimize thread local variable access (brpc)

2024-02-02 Thread via GitHub
zcfh commented on PR #2156: URL: https://github.com/apache/brpc/pull/2156#issuecomment-1923616331 > > 加上这个patch后,稳定出现第一种错误,是 socket.cpp 也有类似的问题吗? > > 是在哪个平台上出现呢?arm 还是 x86 ? 可以贴下 PoC 代码。 x86, `(defined(__aarch64__) || defined(__arm64__))`,去掉后不再core在前面提到的两个位置。

Re: [PR] fix compiler optimize thread local variable access (brpc)

2024-02-01 Thread via GitHub
ehds commented on PR #2156: URL: https://github.com/apache/brpc/pull/2156#issuecomment-1923274012 > 加上这个patch后,稳定出现第一种错误,是 socket.cpp 也有类似的问题吗? 是在哪个平台上出现呢?arm 还是 x86 ? 可以贴下 PoC 代码。 -- This is an automated message from the Apache Git Service. To respond to the message, please log

Re: [PR] fix compiler optimize thread local variable access (brpc)

2024-02-01 Thread via GitHub
zcfh commented on PR #2156: URL: https://github.com/apache/brpc/pull/2156#issuecomment-1922778151 遇到了和 [iss 1860](https://github.com/apache/brpc/issues/1860) 一样的问题。 项目依赖 brpc-0.9.6, 使用clang-11 加上thinlto构建项目,可能出现两种错误 ``` // 第一种 socket.cpp:1070, IsWriteComplete] Check failed: p !=

Re: [PR] fix compiler optimize thread local variable access (brpc)

2023-04-26 Thread via GitHub
wwbmmm merged PR #2156: URL: https://github.com/apache/brpc/pull/2156 -- 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: dev-unsubscr...@brpc.apache.org

Re: [PR] fix compiler optimize thread local variable access (brpc)

2023-03-10 Thread via GitHub
wwbmmm commented on PR #2156: URL: https://github.com/apache/brpc/pull/2156#issuecomment-1463638776 LGTM -- 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,

Re: [PR] fix compiler optimize thread local variable access (brpc)

2023-03-09 Thread via GitHub
ehds commented on code in PR #2156: URL: https://github.com/apache/brpc/pull/2156#discussion_r1131964082 ## CMakeLists.txt: ## @@ -150,6 +150,11 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") endif() endif() +if(CMAKE_CXX_COMPILER_ID MATCHES "(AppleClang)|(Clang)" AND

Re: [PR] fix compiler optimize thread local variable access (brpc)

2023-03-09 Thread via GitHub
wwbmmm commented on code in PR #2156: URL: https://github.com/apache/brpc/pull/2156#discussion_r1131953069 ## CMakeLists.txt: ## @@ -150,6 +150,11 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") endif() endif() +if(CMAKE_CXX_COMPILER_ID MATCHES "(AppleClang)|(Clang)" AND

Re: [PR] fix compiler optimize thread local variable access (brpc)

2023-03-09 Thread via GitHub
ehds commented on PR #2156: URL: https://github.com/apache/brpc/pull/2156#issuecomment-1463229810 > > 1. 新增 `NOT_ALLOW_OPTIMIZE_THREAD_LOCAL_ACCESS` 用于控制是否允许编译器优化 > > 能否自动根据当前编译器和平台来决定是否开启这个宏? done, 根据issue的反馈信息,目前仅针对 Clang/AppleClang 并且是 ARM/AArch 架构平台关闭优化。 -- This is an

Re: [PR] fix compiler optimize thread local variable access (brpc)

2023-03-09 Thread via GitHub
wwbmmm commented on PR #2156: URL: https://github.com/apache/brpc/pull/2156#issuecomment-1463116051 > 1. 新增 `NOT_ALLOW_OPTIMIZE_THREAD_LOCAL_ACCESS` 用于控制是否允许编译器优化 能否自动根据当前编译器和平台来决定是否开启这个宏? -- This is an automated message from the Apache Git Service. To respond to the message,

[PR] fix compiler optimize thread local variable access (brpc)

2023-03-07 Thread via GitHub
ehds opened a new pull request, #2156: URL: https://github.com/apache/brpc/pull/2156 ### What problem does this PR solve? Issue Number:https://github.com/apache/brpc/issues/1776, https://github.com/apache/brpc/issues/1407,