-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Describe the bug (描述bug)
服务器上程序使用 Brpc,发现有些客户端 ssh 登录执行出现 Fail to define xxx which is already defined as xxx 并退出,定位发现是使用中文字符集导致的错误,具体错误栈如下
To Reproduce (复现方法)
(gdb) bt
#0 butil::DescribeCustomizedErrno (error_code=1002, error_name=0x7fffd2cd23da "brpc::ENOMETHOD", description=0x7fffd2cd23cb "No such method")
at ../brpc/butil/errno.cpp:47
#1 0x00007fffd23887ac in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at ../brpc/brpc/controller.cpp:55
#2 0x00007fffd2388c8d in _GLOBAL__sub_I_controller.cpp(void) () at ../brpc/brpc/controller.cpp:1488
#3 0x00007ffff7dea503 in _dl_init_internal () from /lib64/ld-linux-x86-64.so.2
#4 0x00007ffff7deec16 in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
#5 0x00007ffff7dea314 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#6 0x00007ffff7dee30b in _dl_open () from /lib64/ld-linux-x86-64.so.2
#7 0x00007ffff7596fbb in dlopen_doit () from /lib64/libdl.so.2
#8 0x00007ffff7dea314 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#9 0x00007ffff75975bd in _dlerror_run () from /lib64/libdl.so.2
#10 0x00007ffff7597051 in dlopen@@GLIBC_2.2.5 () from /lib64/libdl.so.2
#11 0x00007ffff6ab7a42 in os::dll_load(char const*, char*, int) () from /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-1.b12.el7_4.x86_64/jre/lib/amd64/server/libjvm.so
#12 0x00007ffff68c829c in JVM_LoadLibrary () from /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-1.b12.el7_4.x86_64/jre/lib/amd64/server/libjvm.so
#13 0x00007ffff53b4623 in Java_java_lang_ClassLoader_00024NativeLibrary_load () from /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-1.b12.el7_4.x86_64/jre/lib/amd64/libjava.so
#14 0x00007fffe10174d4 in ?? ()
#15 0x000000076eaad100 in ?? ()
#16 0x0000000000000009 in ?? ()
#17 0x0000000771361780 in ?? ()
#18 0x00007ffff7fe8d58 in ?? ()
#19 0x0000000000000000 in ?? ()
(gdb) n
58 in ../brpc/butil/errno.cpp
1: desc = 0x7ffff00da480 "Unknown error 1002"
以上是正常的的情况,debug 可以看到 desc 内容为 "Unknown error 1002",当使用中文字符集时,desc 内容变成 "未知的错误 1002",找到对应代码如下,butil/errno.cpp 中,对 Linux 系统使用了字符串比较 Unknown error,导致中文字符集时程序退出
#if defined(OS_MACOSX)
const int rc = strerror_r(error_code, tls_error_buf, ERROR_BUFSIZE);
if (rc != EINVAL)
#else
desc = strerror_r(error_code, tls_error_buf, ERROR_BUFSIZE);
if (desc && strncmp(desc, "Unknown error", 13) != 0)
#endif
{
fprintf(stderr, "Fail to define %s(%d) which is already defined as `%s', abort.",
error_name, error_code, desc);
_exit(1);
}
}
Expected behavior (期望行为)
期望修改此处字符串比较的逻辑,不应依赖于特定系统语言
Versions (各种版本)
OS:
Compiler:
brpc:
protobuf:
Additional context/screenshots (更多上下文/截图)