Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

Mac 启动Crash: 0 failed in bufferevent_decref_and_unlock_ #23

Closed
xuaofei opened this issue Oct 5, 2021 · 5 comments
Closed

Mac 启动Crash: 0 failed in bufferevent_decref_and_unlock_ #23

xuaofei opened this issue Oct 5, 2021 · 5 comments

Comments

@xuaofei
Copy link

xuaofei commented Oct 5, 2021

error: module importing failed: invalid pathname
�[01;32m2021-10-05 17:04:22 [thread-main] INFO: �[0mworker threads: 4, config: /Users/xxxx/.config/pegas/config
�[01;32m2021-10-05 17:04:22 [thread-3056] INFO: �[0mcurrent server: 0, server length: 2
�[01;32m2021-10-05 17:04:22 [thread-3056] INFO: �[0mController Listening at: /tmp/pegas.sock
�[01;32m2021-10-05 17:04:22 [thread-6896] INFO: �[0mListening at 0.0.0.0:1080
�[01;32m2021-10-05 17:04:22 [thread-3744] INFO: �[0mListening at 0.0.0.0:1080
�[01;32m2021-10-05 17:04:22 [thread-3472] INFO: �[0mListening at 0.0.0.0:1080
�[01;32m2021-10-05 17:04:22 [thread-0320] INFO: �[0mListening at 0.0.0.0:1080
[err] bufferevent.c:713: Assertion bufev_private->refcnt > 0 failed in bufferevent_decref_and_unlock_
Program ended with exit code: 9

Darwin Mac-mini.local 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64

Mac-mini-$ cmake -DCMAKE_BUILD_TYPE=Release -DWITH_APPLET=ON .. -G "Xcode"
-- The C compiler identification is AppleClang 12.0.0.12000032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found libevent2 includes: /usr/local/include/event2/event.h
-- Found libevent2 library: /usr/local/lib/libevent.dylib
-- Found libevent2 core library: /usr/local/lib/libevent_core.dylib
-- Found libevent2 extra library: /usr/local/lib/libevent_extra.dylib
-- Found libevent2 openssl library: /usr/local/lib/libevent_openssl.dylib
-- Found libevent2 mbedtls library: LIBEVENT2_MBEDTLS_LIBRARIES-NOTFOUND
-- Found openssl library root: /usr/local/Cellar/openssl@1.1/1.1.1l/
-- Found OpenSSL: /usr/local/Cellar/openssl@1.1/1.1.1l/lib/libcrypto.dylib (found suitable version "1.1.1l", minimum required is "1.1.0")
-- Found openssl libraries: /usr/local/Cellar/openssl@1.1/1.1.1l/lib/libssl.dylib;/usr/local/Cellar/openssl@1.1/1.1.1l/lib/libcrypto.dylib
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/xxxx/Desktop/Code/MyProject/pegasocks/build

Mac-mini-:build xxxx$ brew install libevent
Warning: libevent 2.1.12 is already installed and up-to-date.
To reinstall 2.1.12, run:
brew reinstall libevent

@xuaofei xuaofei changed the title Mac 启动Crash [err] bufferevent.c:713: Assertion bufev_private->refcnt > 0 failed in bufferevent_decref_and_unlock_ Mac 启动Crash: 0 failed in bufferevent_decref_and_unlock_ Oct 5, 2021
@chux0519
Copy link
Owner

chux0519 commented Oct 5, 2021

不太确定是什么原因,依赖看起来都是满足的,不使用 Xcode ,直接编译最新的 master 分支试试看

mkdir build && cd build

cmake -DCMAKE_BUILD_TYPE=Release -DWITH_APPLET=ON ..

make -j

看看可以启动吗,如果还是遇到问题,手动编译安装最新的 libevent 再试一次

如果还是遇到同样的问题,麻烦你在 Debug 模式下,lldb 启动它,crash 后 bt 一下,看看输出。

@xuaofei
Copy link
Author

xuaofei commented Oct 5, 2021

不使用Xcode直接make -j也有问题。奔溃原因应该是一致的:bufferevent_decref_and_unlock_

image

另外发现brew install libevent 是安装的2.1.12版本但是看到目录下面是libevent-2.1.7.dylib 不清楚是不是正常情况。

image

@chux0519
Copy link
Owner

chux0519 commented Oct 5, 2021

刚用 mac 试了下,发现 brew 安装的 libevent,lib 的版本号也不一致

[chux0519@Yongshengs-MacBook-Pro build]$ ls  /usr/local/Cellar/libevent/2.1.12/lib/
libevent-2.1.7.dylib       libevent_core.a             libevent_extra.dylib          libevent_pthreads-2.1.7.dylib
libevent.a                 libevent_core.dylib         libevent_openssl-2.1.7.dylib  libevent_pthreads.a
libevent.dylib             libevent_extra-2.1.7.dylib  libevent_openssl.a            libevent_pthreads.dylib
libevent_core-2.1.7.dylib  libevent_extra.a            libevent_openssl.dylib        pkgconfig

这里应该是正常情况,后面的 7 应该是 7 月发布的意思,完整的版本号实际上类似:libevent-2.1-7_2.1.12-stable-1

可以先手动编译安装一下最新的 libevent ,然后再编译一下 pegas

> git clone https://github.com/libevent/libevent.git
> cd libevent
> mkdir build && cd build
> cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(pwd) -DOPENSSL_ROOT_DIR=/usr/local/Cellar/openssl\@1.1/1.1.1l/ -DEVENT__DISABLE_MBEDTLS=ON ..
> make -j
> make install

这里会安装最新版本的 libevent 到 build 目录,然后 pull 下最新的 pegasocks 代码,cmake 时指定一下 libevent 版本

> cmake -DCMAKE_BUILD_TYPE=Release -DWITH_APPLET=1 -DLibevent2_ROOT=/Users/$USER/repos/libevent/build ..

也许是最近的一些重构 break 了 2.12 的某些功能(master 分支的 libevent 不存在这个问题),修复后我会更新到这个 issue,目前先暂时这样用一下。

@xuaofei
Copy link
Author

xuaofei commented Oct 5, 2021

按照上面的方式编译libevent ,然后指定libevent目录编译通过并且可以正常运行PegasApp了。

谢谢大大🙏

@chux0519
Copy link
Owner

chux0519 commented Oct 5, 2021

客气了,这个问题还有点奇怪,只在 OSX 上可以复现,后面我再仔细看看。

@xuaofei xuaofei closed this as completed Oct 5, 2021
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