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

terminate called after throwing an instance of 'char const*' #79

Open
bignmllc opened this issue Oct 5, 2021 · 2 comments
Open

terminate called after throwing an instance of 'char const*' #79

bignmllc opened this issue Oct 5, 2021 · 2 comments

Comments

@bignmllc
Copy link

bignmllc commented Oct 5, 2021

In the examples++/http_examples folder, using modified build.sh of:

#!/bin/bash
g++ -o http http.cpp -lsocket++
g++ -o http_2 http_2.cpp -lsocket++
g++ -o http_epoll http_epoll.cpp -lsocket++

everything compiles with no warnings or errors. The http and http_2 programs run fine. However, the http_epoll application runs and terminates with the following output:

$ ./http_epoll
terminate called after throwing an instance of 'char const*'
Aborted

Test environment:

$ g++ --version
g++ (Ubuntu 9.4.0-1ubuntu1~16.04) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ uname -a
Linux asusubuntu16 4.15.0-142-generic #146~16.04.1-Ubuntu SMP Tue Apr 13 09:27:15 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

I tried compiling with g++ v5 but got the same result.

@dermesser
Copy link
Owner

I can't reproduce this, unfortunately. The thrown "const char*" is unfortunate; if you look at the source code it becomes clear that epoll didn't return a ready socket. So for some reason the epoll wait returns without a ready socket -- there can be many reasons for this, I'd recommend using strace to investigate a bit more.

When it works, it looks like this:

socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("139.162.166.18")}, 16) = 0
write(4, "GET / HTTP/1.1\n", 15)        = 15
write(4, "Host: spheniscida.de\n\n", 22) = 22
shutdown(4, SHUT_WR)                    = 0
epoll_ctl(3, EPOLL_CTL_ADD, 4, {events=EPOLLIN, data={u32=3047235328, u64=140736240623360}}) = 0
epoll_wait(3, [{events=EPOLLIN, data={u32=3047235328, u64=140736240623360}}], 128, -1) = 1
read(4, "HTTP/1.1 200 OK\r\nServer: nginx/1"..., 2000) = 311

@bignmllc
Copy link
Author

Thanks for the reply. I have decided on using another socket library that is working with my project.

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