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

Accidental errors : [cppcms_error] Access to unassigned context #78

Open
yangguang0756 opened this issue Dec 17, 2020 · 2 comments
Open

Comments

@yangguang0756
Copy link

ENV:
win10/nginx-1.15.9/fastcgi/cppcms-2.0.0.beta2|1.2.1

only sometimes occur.

How to solve this problem? I need help, thanks.

@artyom-beilis
Copy link
Owner

Can you provide more details - content of the error log? What are you doing.

This exception is thrown when you try to use application().context() or any stuff that requies it (like sessions request/reponse) outside the scope of actual request - i.e. when there is no active request for the application.

Do you have stack trace? (usually it prints it if you use MSVC + Debug Info)

@yangguang0756
Copy link
Author

I have a c++ client remote call EchoController throught httplib. sometimes throw this exception :-(

code:
EchoController::EchoController(::cppcms::service &srv) : cppcms::application(srv)
{
dispatcher().assign("", &EchoController::echo, this);
mapper().assign(""); // default URL
}

void EchoController::echo()
{
BOOSTER_DEBUG("EchoController") << "echo [" << ::GetCurrentThreadId() << "]";

if (request().request_method() == "POST") <==this line throw exception
{
...
}
}

===========
log:
2020-12-17 18:52:13; EchoController, debug: echo [2672] (echocontroller.cpp:87)
2020-12-17 18:52:13; cppcms, error: Caught exception [Access to unassigned context]
00007FFD950CC6B5: booster::stack_trace::trace +0x45
00007FFD955921F9: booster::backtrace::backtrace +0x99
00007FFD955947B2: booster::runtime_error::runtime_error +0x52
00007FFD955940E2: cppcms::cppcms_error::cppcms_error +0x32
00007FFD95621EAE: cppcms::application::context +0xce
00007FFD95621F38: cppcms::application::request +0x28
00007FF700C8CE0A: App::Http::Controllers::EchoController::echo +0x16a
00007FF700C7FCCC: cppcms::url_dispatcher::binder0App::Http::Controllers::EchoController::operator() +0x6c
00007FF700C772BE: std::_Invoker_functor::_Call<cppcms::url_dispatcher::binder0App::Http::Controllers::EchoController & __ptr64> +0x3e
00007FF700C79F8E: std::invoke<cppcms::url_dispatcher::binder0App::Http::Controllers::EchoController & __ptr64> +0x3e
00007FF700C777F2: std::_Invoke_ret<void,cppcms::url_dispatcher::binder0App::Http::Controllers::EchoController & __ptr64> +0x42
00007FF700C87D65: std::_Func_impl<cppcms::url_dispatcher::binder0App::Http::Controllers::EchoController,std::allocator,void>::_Do_call +0x45
00007FFD9559BE34: std::_Func_class::operator() +0x54
00007FFD95632DBD: cppcms::anonymous namespace'::base_handler<std::function<void __cdecl(void)> >::execute_handler +0x2d 00007FFD95631E90: cppcms::anonymous namespace'::base_handler<std::function<void __cdecl(void)> >::dispatch +0x60
00007FFD956274E3: cppcms::url_dispatcher::dispatch +0x193
00007FFD95622E69: cppcms::application::main +0x99
00007FFD9563201B: cppcms::anonymous namespace'::mounted::dispatch +0xbb 00007FFD956274E3: cppcms::url_dispatcher::dispatch +0x193 00007FFD95622E69: cppcms::application::main +0x99 00007FFD95606591: cppcms::http::context::dispatch +0x2c1 00007FFD95606296: cppcms::http::context::dispatch +0x276 00007FFD9560BEF3: cppcms::http::anonymous namespace'::dispatcher::operator() +0x53
00007FFD956086C0: std::_Invoker_functor::_Call<cppcms::http::anonymous namespace'::dispatcher & __ptr64> +0x30 00007FFD95609F50: std::invoke<cppcms::http::anonymous namespace'::dispatcher & __ptr64> +0x30
00007FFD956089D4: std::_Invoke_ret<void,cppcms::http::anonymous namespace'::dispatcher & __ptr64> +0x34 00007FFD9560C8F5: std::_Func_impl<cppcms::http::anonymous namespace'::dispatcher,std::allocator,void>::_Do_call +0x35
00007FFD9559BE34: std::_Func_class::operator() +0x54
00007FFD95615E52: cppcms::impl::thread_pool::worker +0x142
00007FFD956120FE: cppcms::util::details::binderX<cppcms::impl::thread_pool,cppcms::impl::thread_pool * __ptr64>::operator() +0x2e
00007FFD9560E9A0: std::_Invoker_functor::_Call<cppcms::util::details::binderX<cppcms::impl::thread_pool,cppcms::impl::thread_pool * __ptr64> > +0x30
00007FFD9560FB50: std::invoke<cppcms::util::details::binderX<cppcms::impl::thread_pool,cppcms::impl::thread_pool * __ptr64> > +0x30
(http_context.cpp:336)

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