Stiffstream / restinio

Cross-platform, efficient, customizable, and robust asynchronous HTTP(S)/WebSocket server C++ library with the right balance between performance and ease of use
Other
1.15k stars 93 forks source link

Segfault on close websocket #12

Closed jm130794 closed 5 years ago

jm130794 commented 5 years ago

Hello,

I installed restinio with vcpkg. I test your WebSocket example with the Chrome module "Simple WebSocket Client".

I can open the connection but when I close it, I get these errors :

$ LANG=C ./websocket 
[2019-02-26 10:17:47.081] TRACE: starting server on 127.0.0.1:8080
[2019-02-26 10:17:47.081]  INFO: init accept #0
[2019-02-26 10:17:47.081]  INFO: server started on 127.0.0.1:8080
[2019-02-26 10:17:56.707] TRACE: accept connection from 127.0.0.1:41250 on socket #0
[2019-02-26 10:17:56.707] TRACE: [connection:1] start connection with 127.0.0.1:41250
[2019-02-26 10:17:56.707] TRACE: [connection:1] start waiting for request
[2019-02-26 10:17:56.707] TRACE: [connection:1] continue reading request
[2019-02-26 10:17:56.707] TRACE: [connection:1] received 702 bytes
[2019-02-26 10:17:56.708] TRACE: [connection:1] upgrade request received: GET /chat/; Upgrade: 'websocket';
[2019-02-26 10:17:56.708]  INFO: [connection:1] handle upgrade request (#0): GET /chat/
[2019-02-26 10:17:56.708] TRACE: [connection:1] move socket to [ws_connection:1]
[2019-02-26 10:17:56.708] TRACE: [ws_connection:1] start connection with 127.0.0.1:41250
[2019-02-26 10:17:56.708] TRACE: [ws_connection:1] start next write group, size: 1
[2019-02-26 10:17:56.708] TRACE: [ws_connection:1] sending data with buf count: 1, total size: 129
[2019-02-26 10:17:56.708] TRACE: [ws_connection:1] start reading header
[2019-02-26 10:17:56.708] TRACE: [ws_connection:1] continue reading message
[2019-02-26 10:17:56.708] TRACE: [connection:1] destructor called
[2019-02-26 10:17:56.708] TRACE: [ws_connection:1] outgoing data was sent: 129 bytes
[2019-02-26 10:17:56.708] TRACE: [ws_connection:1] finishing current write group
[2019-02-26 10:18:07.562] TRACE: [ws_connection:1] received 6 bytes
[2019-02-26 10:18:07.562] TRACE: [ws_connection:1] start handling connection_close_frame (0x8)
websocket: /donnees/jm/vcpkg/installed/x64-linux/include/restinio/third_party/string-view-lite/string_view.hpp:492: constexpr const CharT& nonstd::sv_lite::basic_string_view<CharT, Traits>::operator[](nonstd::sv_lite::basic_string_view<CharT, Traits>::size_type) const [with CharT = char; Traits = std::char_traits<char>; nonstd::sv_lite::basic_string_view<CharT, Traits>::const_reference = const char&; nonstd::sv_lite::basic_string_view<CharT, Traits>::size_type = long unsigned int]: Assertion `pos < size()' failed.
Abandon (core dumped)

Jean-Marc

eao197 commented 5 years ago

Hi!

Can you provide some info about your environment (OS and compiler)?

jm130794 commented 5 years ago
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.5.0-12ubuntu1~16.04' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.5.0 20171010 (Ubuntu 5.5.0-12ubuntu1~16.04)
eao197 commented 5 years ago

@jm130794 thanks for reporting this issue. We'll investigate it.

But I'm afraid it can take several days because we are now somewhat busy with other projects :(

jm130794 commented 5 years ago

Hi,

OK :)

For information, I tested with Ubuntu 18.04 in a docker environment and I have the same error.

Jean-Marc

eao197 commented 5 years ago

Good news: I can reproduce it on my Ubuntu 16.04 with GCC-5.5. Will investigate what is going on...

eao197 commented 5 years ago

Error found. It is fixed in trunk on BitBucket. We need some time for additional testing, updating mirror, updating vcpkg and so on...

eao197 commented 5 years ago

Hi @jm130794 We have released v.0.4.8.6 with bug fix. This version should be available via vcpkg now.

jm130794 commented 5 years ago

Hi,

Great! Thank you for the speed of the bug correction.

Jean-Marc