Skip to content

example/async1.cpp doesn't detect EOF and thus is running forever. #1

@Corristo

Description

@Corristo

I'm trying to get the async example to run on my machine, and unfortunately it just keeps running forever. I added std::cout statements to each of the web_page_getter private member functions to track progress, and now when running it I'm presented with the following output:

connecting...
sending request...
reading headers...
reading body...

I captured the network traffic generated by the executable with wireshark, and it shows that the entire body has been submitted, yet the program doesn't finish execution. As a sanity check I've also tested example/sync2.cpp, which works just fine.

I've compiled the example on my laptop running Arch linux with both gcc 7.1.1 and clang 4.0.1, with c++14 and c++17 flags and tried both libc++ and libstdc++, but it always has the same behaviour. Any suggestion on how to fix this?

Compiler output:

[manuel@Thinkpad-L440 examples (master *%=)]$ clang++ -std=c++14 -stdlib=libc++ -lpthread -I ../networking-ts-impl-master/include/ -v -g async1.cpp 
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/7.1.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/usr/bin/clang-4.0" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name async1.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -resource-dir /usr/bin/../lib/clang/4.0.1 -I ../networking-ts-impl-master/include/ -internal-isystem /usr/bin/../include/c++/v1 -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/4.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++14 -fdeprecated-macro -fdebug-compilation-dir /home/manuel/Entwicklung/Cpp/cppnow-2017-networking-ts-workshop/examples -ferror-limit 19 -fmessage-length 227 -stack-protector 2 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/async1-4ee192.o -x c++ async1.cpp
clang -cc1 version 4.0.1 based upon LLVM 4.0.1 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 ../networking-ts-impl-master/include
 /usr/bin/../include/c++/v1
 /usr/local/include
 /usr/bin/../lib/clang/4.0.1/include
 /usr/include
End of search list.
 "/usr/bin/ld" -pie --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../lib64/Scrt1.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../lib64/crti.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/crtbeginS.o -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1 -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib -lpthread /tmp/async1-4ee192.o -lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/crtendS.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../lib64/crtn.o

GDB backtrace

#0  0x00007ffff7bc81ad in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007ffff79381cf in std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) () from /usr/lib/libc++.so.1
#2  0x00007ffff793b2db in std::__1::__assoc_sub_state::__sub_wait(std::__1::unique_lock<std::__1::mutex>&) () from /usr/lib/libc++.so.1
#3  0x000055555557de03 in std::__1::__assoc_state<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::move (this=0x55555578b4e0) at /usr/bin/../include/c++/v1/future:691
#4  0x000055555555bbcc in std::__1::future<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::get (this=0x7fffffffe898) at /usr/bin/../include/c++/v1/future:1177
#5  0x00005555555599a4 in main () at async1.cpp:145

Note: async1.cpp:145 is the line auto result = f.get().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions