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

beast migration path to coroutine2? #1055

Closed
jdmairs opened this issue Mar 2, 2018 · 3 comments
Closed

beast migration path to coroutine2? #1055

jdmairs opened this issue Mar 2, 2018 · 3 comments

Comments

@jdmairs
Copy link

jdmairs commented Mar 2, 2018

I shamefully admit part of my reason for posting here is how quickly Vinnie responds to issues. This is most likely not a Beast problem but I'm hoping to tap his knowledge on co-routines.

I built a REST based server built upon the http_client_coro.cpp example which uses stackful coroutines. During one of our request handlers the app needs to reread an xml config file using boost::property_tree. In the read_xml_internal method we get a Access Violation exception. The top of the stack shows the function _chkstk() being called. Using VS2017 core guideline checker we get C6262 warning in the boost property tree that too much stack space is being used. We set the Linker->System->Stack Reserve Size to 4194304 but the crash still happens.

This call to reload the property tree does not fail if we call it outside of the lambda that gets invoked by the REST server.

No large arrays are being used.

Would coro2 or stackless coroutines be a solution?

Any thoughts?

@vinniefalco
Copy link
Member

vinniefalco commented Mar 2, 2018

Always glad to help when I can.

We set the Linker->System->Stack Reserve Size to 4194304 but the crash still happens.

LOL...sorry for having a little chuckle at your expense. This setting only affects the stacks created by the compiler. It can't affect the stacks created by the coroutine library. When you spawn the coroutine you can adjust the stack size by passing in some additional settings. For example, this spawns a coroutine with 2MB of stack space:

boost::asio::spawn(ioc, f, boost::coroutines::attributes(2 * 1024 * 1024));

Or you can adjust the settings used by Boost.PropertyTree, as illustrated in the answer here:

https://stackoverflow.com/questions/41030285/boostproperty-treeread-xml-segfaults-in-an-asio-handler-spawned-using-boost

Hope this helps!

@jdmairs
Copy link
Author

jdmairs commented Mar 2, 2018

Wow how cool that we can fix it either via coroutine or ptree. The power/design of boost continues to amaze.

@jdmairs jdmairs closed this as completed Mar 2, 2018
@jdmairs
Copy link
Author

jdmairs commented Mar 2, 2018

Thanks so much again!

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