|
Boost Users : |
Subject: [Boost-users] [Coroutine] Assertion when coroutine is not run
From: Brian Ravnsgaard Riis (brian_at_[hidden])
Date: 2014-03-09 20:37:45
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I've been toying with Boost.Coroutine lately. For starters I have
tried to implement a message parser using the library. For this
purpose I have two coroutine<char>::push_type in a containing class.
These are initialized at class construction with a lambda. One
coroutine parses the message header, the other the body.
This all worked fine. Until I had a test case where I was only
interested in the message header, so I never called the
message-body-coroutine. At object destruction I get a this assertion:
replyparser:
/usr/local/include/boost/coroutine/detail/push_coroutine_object.hpp:167:
void boost::coroutines::detail::push_coroutine_object<char, <lambda at
src/replyparser.cpp:303:22>,
boost::coroutines::detail::standard_stack_allocator,
std::allocator<boost::coroutines::push_coroutine<char> >,
boost::coroutines::pull_coroutine<char> >::run() [X = char, Y =
<lambda at src/replyparser.cpp:303:22>, Z =
boost::coroutines::detail::standard_stack_allocator, V =
std::allocator<boost::coroutines::push_coroutine<char> >, W =
boost::coroutines::pull_coroutine<char>]: Assertion `hldr_from->data'
failed.
The message-body coroutine is really simple; it just takes the
characters and stuffs them into a std::string until the string size is
equal to the expected length of the body (parsed from the header):
[&](coroutine<char>::pull_type& c)
{
content.push_back(c.get());
while(content.size() != contentLength)
{
c();
content.push_back(c.get());
}
validResult = true;
}
This works just fine when I parse the message body, but when I (choose
to) ignore the message body, so the coroutine is never called, I get
the above assertion.
I have a feeling I'm missing some obvious detail about this. Of course
I would normally not skip the message body, but there is a chance the
length is 0, i.e. there *is* no message body. I'd prefer to have no
assertions in that case.
What am I doing wrong?
/Brian Riis
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJTHQlPAAoJEFES4N8QrEodJ+MH/1z+N+YnXrCm3xPnp7wAlM+w
3RZkeNOOJ0h67nmBHRJXj3A3+t/Hy+FZV/SUBDMtCwx/zIH5fZZtsBaw89frAsdI
SPmLiwG6NgBoBSV8Pih4gD+k4LvTbYh5AQLF2ssB/WAVZODk92iz4sNrNFVwThFn
S68NStkEyyXElrCzkd3w0QQD8sD2OGWAW0YlHLGhUXlsouWRyd9VKAbEXdrTKLVQ
I0ciL87AzOKsfrfV89U1eQh5uHEgg8ZcDa459ieqeOISXhNJI/ba8rv6mkXGEseB
U7wRr7M1XMdHolPiFlUEKrUocdAPLS/AjeVfcGkJSzc2bhka08qu4EMTgqkOhtY=
=G1Y2
-----END PGP SIGNATURE-----
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net