Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webclient在gc的时候可能触发崩溃 #15

Closed
xzzwandi opened this issue Feb 27, 2018 · 7 comments
Closed

webclient在gc的时候可能触发崩溃 #15

xzzwandi opened this issue Feb 27, 2018 · 7 comments

Comments

@xzzwandi
Copy link

服务器使用的是skynet框架,最近有时出现崩溃问题,不好重现
收集几个coredump,gdb里看到的都是在webclient_destory的时候触发崩溃
以下是gdb的栈:
(gdb) bt
#0 0x00007fdfdbc1988a in ?? ()
#1 0x00007fdfe942098f in ?? () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
#2 0x00007fdfe941ed56 in ?? () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
#3 0x00007fdfe942e440 in sk_pop_free () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
#4 0x00007fdfe941f0dc in ENGINE_cleanup () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
#5 0x00007fdfe01e352e in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#6 0x00007fdfe01e3ec9 in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#7 0x00007fdfe01bf695 in curl_global_cleanup () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#8 0x00007fdfe03fe47c in webclient_destory (l=0x7fdfe1b5ed08) at lualib-src/lua-webclient.c:87
#9 0x0000000000414739 in luaD_precall (L=L@entry=0x7fdfe1b5ed08, func=0x7fdfe1a79930, nresults=0) at ldo.c:434
#10 0x0000000000414a03 in luaD_call (L=L@entry=0x7fdfe1b5ed08, func=, nResults=) at ldo.c:498
#11 0x0000000000414a61 in luaD_callnoyield (L=0x7fdfe1b5ed08, func=, nResults=) at ldo.c:509
#12 0x0000000000413e6f in luaD_rawrunprotected (L=L@entry=0x7fdfe1b5ed08, f=0x416010 , ud=0x0) at ldo.c:142
#13 0x0000000000414d4d in luaD_pcall (L=0x7fdfe1b5ed08, func=, u=, old_top=48, ef=) at ldo.c:729
#14 0x0000000000415f1c in GCTM (L=L@entry=0x7fdfe1b5ed08, propagateerrors=propagateerrors@entry=0) at lgc.c:833
#15 0x00000000004175aa in callallpendingfinalizers (L=0x7fdfe1b5ed08) at lgc.c:872
#16 luaC_freeallobjects (L=0x7fdfe1b5ed08) at lgc.c:981
#17 0x000000000041bbce in close_state (L=0x7fdfe1b5ed08) at lstate.c:245
#18 0x000000000041c0c0 in lua_close (L=) at lstate.c:344
#19 0x00007fdfe7dfc7ac in snlua_release (l=0x7fdfe8b79470) at service-src/service_snlua.c:192
#20 0x000000000040abfa in delete_context (ctx=0x7fdfe0991400) at skynet-src/skynet_server.c:213
#21 skynet_context_release (ctx=ctx@entry=0x7fdfe0991400) at skynet-src/skynet_server.c:223
#22 0x000000000040b1fd in skynet_context_message_dispatch (sm=sm@entry=0x7fdfe8a168a0, q=0x7fdfe1b9c500, q@entry=0x0, weight=weight@entry=0) at skynet-src/skynet_server.c:348
#23 0x000000000040b87d in thread_worker (p=) at skynet-src/skynet_start.c:162
#24 0x00007fdfe9e3e184 in start_thread (arg=0x7fdfe2df0700) at pthread_create.c:312
#25 0x00007fdfe907d03d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

请问这可能是什么问题?从哪个方向查?谢谢!

@dpull
Copy link
Owner

dpull commented Feb 27, 2018

了解一下

  1. 进程中存在几个webclient实例?
  2. curl版本是多少?OpenSSL版本是多少?

@xzzwandi
Copy link
Author

1、我们的webclient有很多, 但只有一个有实例有通信,且这个不会摧毁, 其他都是只用了urlencode功能
2、curl 7.35.0 (x86_64-pc-linux-gnu) libcurl/7.35.0
OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3

@dpull
Copy link
Owner

dpull commented Feb 28, 2018

/* true globals -- for curl_global_init() and curl_global_cleanup() */
static unsigned int initialized;

中这个变量是没有加锁的,可否尝试将 webclient_destory 和 webclient_create 增加一个Mutex测试一下,看可否解决问题

@xzzwandi
Copy link
Author

xzzwandi commented Mar 1, 2018

我现在尝试只使用一个webclient实例,这个问题不是很好重现,我再运行观察一段时间看看是否解决吧。谢谢。

@dpull
Copy link
Owner

dpull commented Mar 1, 2018

https://curl.haxx.se/libcurl/c/curl_global_init.html

This function is not thread safe. You must not call it when any other thread in the program (i.e. a thread sharing the same memory) is running. This doesn't just mean no other thread that is using libcurl. Because curl_global_init calls functions of other libraries that are similarly thread unsafe, it could conflict with any other thread that uses these other libraries.

我本周末补充上mutex 保证线程安全

@dpull
Copy link
Owner

dpull commented Mar 13, 2018

我提交了 你看看

@xzzwandi
Copy link
Author

好的,多谢了!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants