Description
I deploy server with https in arm environment, and run it ,the following is stack with bt
x0000fffff7bc752c in malloc () from /lib/aarch64-linux-gnu/libc.so.6
(gdb) bt
#0 0x0000fffff7bc752c in malloc () from /lib/aarch64-linux-gnu/libc.so.6
#1 0x0000000000534ad4 in CRYPTO_zalloc ()
#2 0x00000000005446ac in CRYPTO_THREAD_lock_new ()
#3 0x000000000065b304 in ossl_ecx_key_new ()
#4 0x00000000005cddd4 in x25519_gen ()
#5 0x0000000000518a4c in evp_keymgmt_util_gen ()
#6 0x000000000052555c in EVP_PKEY_keygen ()
#7 0x0000000000465e34 in ssl_generate_pkey ()
#8 0x00000000004998f4 in tls_construct_stoc_key_share ()
#9 0x00000000004905c4 in tls_construct_extensions ()
#10 0x00000000004a8ac8 in tls_construct_server_hello ()
#11 0x000000000049adc0 in state_machine.part ()
#12 0x0000000000473a04 in SSL_do_handshake ()
#13 0x0000000000421f1c in httplib::detail::ssl_connect_or_accept_nonblocking<int ()(ssl_st)> (
sock=6, ssl=0xffffe8000b60, ssl_connect_or_accept=0x473aa0 <SSL_accept>, timeout_sec=5,
timeout_usec=0) at /home/tuo/code/cpp-net/httplib.h:7179
#14 0x000000000041a5f0 in httplib::SSLServer::process_and_close_socket(int)::{lambda(ssl_st*)#1}::operator()(ssl_st*) const (__closure=0xfffff6b4a738, ssl2=0xffffe8000b60)
at /home/tuo/code/cpp-net/httplib.h:7451
#15 0x0000000000422090 in httplib::detail::ssl_new<httplib::SSLServer::process_and_close_socket(int)::{lambda(ssl_st*)#1}, httplib::SSLServer::process_and_close_socket(int)::{lambda(ssl_st*)#2}>(int, ssl_ctx_st*, std::mutex&, httplib::SSLServer::process_and_close_socket(int)::{lambda(ssl_st*)#1}, httplib::SSLServer::process_and_close_socket(int)::{lambda(ssl_st*)#2}) (sock=6, ctx=0x885f50,
ctx_mutex=..., SSL_connect_or_accept=..., setup=...) at /home/tuo/code/cpp-net/httplib.h:7145
#16 0x000000000041a71c in httplib::SSLServer::process_and_close_socket (this=0xfffffffff030,
sock=6) at /home/tuo/code/cpp-net/httplib.h:7448
#17 0x0000000000416d8c in httplib::Server::listen_internal()::{lambda()#1}::operator()() const (
__closure=0xfffff6b4a880) at /home/tuo/code/cpp-net/httplib.h:5455
#18 0x0000000000428fdc in std::_Function_handler<void (), httplib::Server::listen_internal()::{lambda()#1}>::_M_invoke(std::_Any_data const&) (__functor=...)
at /usr/local/arm/9.2/aarch64--glibc--stable-2020.08-1/aarch64-buildroot-linux-gnu/include/c++/9.3.0/bits/std_function.h:300
#19 0x000000000041b9b8 in std::function<void ()>::operator()() const (this=0xfffff6b4a880)
at /usr/local/arm/9.2/aarch64--glibc--stable-2020.08-1/aarch64-buildroot-linux-gnu/include/c++/9.3.0/bits/std_function.h:688
#20 0x000000000040c758 in httplib::ThreadPool::worker::operator() (this=0x8cfee8)
at /home/tuo/code/cpp-net/httplib.h:587
#21 0x00000000004635a8 in std::__invoke_impl<void, httplib::ThreadPool::worker> (__f=...)
at /usr/local/arm/9.2/aarch64--glibc--stable-2020.08-1/aarch64-buildroot-linux-gnu/include/c++/9.3.0/bits/invoke.h:60
#22 0x000000000046354c in std::__invokehttplib::ThreadPool::worker (__fn=...)
at /usr/local/arm/9.2/aarch64--glibc--stable-2020.08-1/aarch64-buildroot-linux-gnu/include/c++/9.3.0/bits/invoke.h:95
#23 0x00000000004634e8 in std::thread::_Invoker<std::tuplehttplib::ThreadPool::worker >::_M_invoke<0ul> (this=0x8cfee8)
at /usr/local/arm/9.2/aarch64--glibc--stable-2020.08-1/aarch64-buildroot-linux-gnu/include/c++/9--Type for more, q to quit, c to continue without paging--
.3.0/thread:244
#24 0x0000000000463450 in std::thread::_Invoker<std::tuplehttplib::ThreadPool::worker >::operator() (this=0x8cfee8)
at /usr/local/arm/9.2/aarch64--glibc--stable-2020.08-1/aarch64-buildroot-linux-gnu/include/c++/9.3.0/thread:251
#25 0x00000000004633ec in std::thread::_State_impl<std::thread::_Invoker<std::tuplehttplib::ThreadPool::worker > >::_M_run (this=0x8cfee0)
at /usr/local/arm/9.2/aarch64--glibc--stable-2020.08-1/aarch64-buildroot-linux-gnu/include/c++/9.3.0/thread:195
#26 0x0000fffff7e5cfac in ?? () from /lib/aarch64-linux-gnu/libstdc++.so.6
#27 0x0000fffff7f90624 in start_thread () from /lib/aarch64-linux-gnu/libpthread.so.0
#28 0x0000fffff7c1f49c in ?? () from /lib/aarch64-linux-gnu/libc.so.6
double free or corruption (fasttop)
the code is following
`#include "httplib.h"
#define SERVER_CERT_FILE "./cacert.pem"
#define SERVER_PRIVATE_KEY_FILE "./privkey.pem"
int main(int argc, char **argv)
{
using namespace httplib;
httplib::SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE);
svr.Get("/hi", [](const Request& req, Response& res) {
res.set_content("Hello World!", "text/plain");
});
svr.Get(R"(/numbers/(\d+))", [&](const Request& req, Response& res) {
auto numbers = req.matches[1];
res.set_content(numbers, "text/plain");
});
svr.Get("/body-header-param", [](const Request& req, Response& res) {
if (req.has_header("Content-Length")) {
auto val = req.get_header_value("Content-Length");
}
if (req.has_param("key")) {
auto val = req.get_param_value("key");
}
res.set_content(req.body, "text/plain");
});
svr.Get("/stop", [&](const Request& req, Response& res) {
svr.stop();
});
int port = 1234;
std::string ip = "10.8.125.64";
if (argc == 3)
{
port = atoi(argv[2]);
ip = argv[1];
} else {
std::cout << "httpDemo-server " << "[ip] [port] default port 1234" << std::endl;
return 0;
}
std::cout << "ip: " << ip << " port : " << port;
auto status = svr.listen(ip.c_str(), port);
std::cout << " : " << status << std::endl;
}`