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

Restful service and schedule HTTP client work on service run-loop cause core dump! #249

Closed
oleacs opened this issue Sep 28, 2017 · 3 comments
Assignees
Milestone

Comments

@oleacs
Copy link

oleacs commented Sep 28, 2017

#include <memory>
#include <cstdio>
#include <cstdlib>
#include <restbed>
#include <chrono>

using namespace std;
using namespace restbed;

void get_method_handler( const shared_ptr< Session > session )
{
    session->close( OK, "Hello, World!", { { "Content-Length", "13" } } );
}

void test()
{
    auto request = make_shared< Request >( Uri( "http://10.45.80.26/zcm-application/applications/2051" ) );
    request->set_header( "Accept", "*/*" );

    auto response = Http::sync( request );

    fprintf( stderr, "*** Response ***\n" );
    fprintf( stderr, "Status Code:    %i\n", response->get_status_code( ) );
    fprintf( stderr, "Status Message: %s\n", response->get_status_message( ).data( ) );
    fprintf( stderr, "HTTP Version:   %.1f\n", response->get_version( ) );
    fprintf( stderr, "HTTP Protocol:  %s\n", response->get_protocol( ).data( ) );

}


int main( const int, const char** )
{
    auto resource = make_shared< Resource >( );
    resource->set_path( "/resource" );
    resource->set_method_handler( "GET", get_method_handler );
    
    auto settings = make_shared< Settings >( );
    settings->set_port( 1984 );
    settings->set_default_header( "Connection", "close" );
    
    Service service;
    service.publish( resource );
    service.schedule( test, chrono::milliseconds( 1000 ) );
    
    service.start( settings );

    return EXIT_SUCCESS;
}

scene:
run program then send

curl -w'\n' -v -XGET 'http://localhost:1984/resource'

core info:
Reading symbols from /home/smartguys/src/ocsr90/lss/bin/Test...(no debugging symbols found)...done.
[New LWP 19725]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib64/libthread_db.so.1".
Core was generated by `./Test'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007ffff7ba2a27 in std::_Function_handler<void (std::shared_ptrrestbed::Session), restbed::detail::ServiceImpl::create_session(std::shared_ptr<asio::basic_stream_socketasio::ip::tcp > const&, std::error_code const&) const::{lambda(std::shared_ptrrestbed::Session)#1}>::_M_invoke(std::_Any_data const&, std::shared_ptrrestbed::Session&&) () from /home/smartguys/tools/runtime/lib/librestbed.so.4
Missing separate debuginfos, use: debuginfo-install glibc-2.17-157.el7_3.1.x86_64 libgcc-4.8.5-11.el7.x86_64 libstdc++-4.8.5-11.el7.x86_64
(gdb) where
#0 0x00007ffff7ba2a27 in std::_Function_handler<void (std::shared_ptrrestbed::Session), restbed::detail::ServiceImpl::create_session(std::shared_ptr<asio::basic_stream_socketasio::ip::tcp > const&, std::error_code const&) const::{lambda(std::shared_ptrrestbed::Session)#1}>::_M_invoke(std::_Any_data const&, std::shared_ptrrestbed::Session&&) () from /home/smartguys/tools/runtime/lib/librestbed.so.4
#1 0x00007ffff7b8570e in restbed::SessionManager::create(std::function<void (std::shared_ptrrestbed::Session)> const&) ()
from /home/smartguys/tools/runtime/lib/librestbed.so.4
#2 0x00007ffff7ba0881 in restbed::detail::ServiceImpl::create_session(std::shared_ptr<asio::basic_stream_socketasio::ip::tcp > const&, std::error_code const&) const () from /home/smartguys/tools/runtime/lib/librestbed.so.4
#3 0x00007ffff7bab030 in asio::detail::reactive_socket_accept_op<asio::basic_socketasio::ip::tcp, asio::ip::tcp, std::_Bind<std::_Mem_fn<void (restbed::detail::ServiceImpl::)(std::shared_ptr<asio::basic_stream_socketasio::ip::tcp > const&, std::error_code const&) const> (restbed::detail::ServiceImpl const, std::shared_ptr<asio::basic_stream_socketasio::ip::tcp >, std::_Placeholder<1>)> >::do_complete(void*, asio::detail::scheduler_operation*, std::error_code const&, unsigned long) () from /home/smartguys/tools/runtime/lib/librestbed.so.4
#4 0x00007ffff7b9a26e in asio::detail::epoll_reactor::descriptor_state::do_complete(void*, asio::detail::scheduler_operation*, std::error_code const&, unsigned long) () from /home/smartguys/tools/runtime/lib/librestbed.so.4
#5 0x00007ffff7b6c322 in restbed::Service::start(std::shared_ptr<restbed::Settings const> const&) ()
from /home/smartguys/tools/runtime/lib/librestbed.so.4
#6 0x00000000004031e9 in main ()

@oleacs oleacs changed the title thread bug cause core dump! bug cause core dump! Sep 28, 2017
@oleacs oleacs changed the title bug cause core dump! schedule HTTP client work on service run-loop cause core dump! Sep 28, 2017
@oleacs oleacs changed the title schedule HTTP client work on service run-loop cause core dump! Restful service and schedule HTTP client work on service run-loop cause core dump! Sep 28, 2017
@ben-crowhurst
Copy link
Member

Will take a look thanks.

@ben-crowhurst
Copy link
Member

@oleacs I apologize for the delay. This ticket managed to get lost in the all the static.

I've attempted to replicate your issue as stated above, and also by changing the supplied request URL, with no luck.

I saw a slow response time due to the repeated test( ) HTTP requests chewing up ASIO. Can you provide any further information and I'll prioritise this ticket?

@ben-crowhurst ben-crowhurst self-assigned this Apr 2, 2018
@ben-crowhurst ben-crowhurst added this to the 4.7 milestone Apr 2, 2018
@ben-crowhurst
Copy link
Member

No activity from the original author. Please reopen if this is still causing problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants