-
Notifications
You must be signed in to change notification settings - Fork 38
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
Windows, Hello World (server) crashes in release #56
Comments
Were you ever able to solve this? |
@kirbyfan64 could you please confirm this issue on latest master? |
Looks like it...if I build in debug instead, I get:
I'll check out a debugger for an actual traceback... |
Traceback:
Yes, this sucks, but I can't get lldb to read pdb info, and I'm still trying to get a Clang build working... |
I tried the example from readme in common mode and it did not crash for me. (VS2015, VS2017) Click to expand#define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST
#include <iostream>
#include <fstream>
#include <boost/application.hpp>
using namespace boost;
// my application code
class myapp
{
public:
myapp(application::context& context)
: context_(context)
{
}
void worker()
{
// my application behaviour
// dump args
std::vector<std::string> arg_vector =
context_.find<application::args>()->arg_vector();
my_log_file_ << "-----------------------------" << std::endl;
my_log_file_ << "---------- Arg List ---------" << std::endl;
my_log_file_ << "-----------------------------" << std::endl;
// only print args on screen
for(std::vector<std::string>::iterator it = arg_vector.begin();
it != arg_vector.end(); ++it) {
my_log_file_ << *it << std::endl;
}
my_log_file_ << "-----------------------------" << std::endl;
// run logic
boost::shared_ptr<application::status> st =
context_.find<application::status>();
for(int count = 0; st->state() != application::status::stopped && count < 50; ++count)
{
boost::this_thread::sleep(boost::posix_time::milliseconds(100));
if(st->state() == application::status::paused)
my_log_file_ << count << ", paused..." << std::endl;
else
my_log_file_ << count << ", running..." << std::endl;
}
}
// param
int operator()()
{
std::string logfile
= context_.find<application::path>()->executable_path().string() + "/log.txt";
my_log_file_.open(logfile.c_str());
my_log_file_ << "Start Log..." << std::endl;
#if 0
// launch a work thread
*boost::thread thread(&myapp::worker, this);
context_.find<application::wait_for_termination_request>()->wait();
#else
// to run direct
worker();
#endif
return 0;
}
// windows/posix
bool stop()
{
my_log_file_ << "Stoping my application..." << std::endl;
my_log_file_.close();
return true; // return true to stop, false to ignore
}
// windows specific (ignored on posix)
bool pause()
{
my_log_file_ << "Pause my application..." << std::endl;
return true; // return true to pause, false to ignore
}
bool resume()
{
my_log_file_ << "Resume my application..." << std::endl;
return true; // return true to resume, false to ignore
}
private:
std::ofstream my_log_file_;
application::context& context_;
};
int main(int argc, char *argv[])
{
application::context app_context;
// auto_handler will automatically add termination, pause and resume (windows) handlers
application::auto_handler<myapp> app(app_context);
// my server aspects
// to handle args
app_context.insert<application::args>(
boost::make_shared<application::args>(argc, argv));
// my server instantiation
boost::system::error_code ec;
int result = application::launch<application::common/*server*/>(app, app_context, ec);
if(ec)
{
std::cout << "[E] " << ec.message()
<< " <" << ec.value() << "> " << std::endl;
}
return result;
} |
@kirbyfan64 @AldrichChen Could you please confirm that issue is gone, or provide MCVE for the issue? Thank you. P.S. |
I am trying to start a tiny service on my pc. And I copy the example provided in README entirely.
Then I use service_setup_ex.exe to register the service on my pc. The problem shows as soon as I click start the service.
Since I cannot debug a "server" mode app, I change the mode to "common". Then I found the crash happens at
my_log_file_ << "Start Log..." << std::endl;
It prompts to show an "Access Violation" exception.
But this only happens in release mode, not in debug mode.
Besides, I also have a try on the simple_server_example. The same problems happened.
The text was updated successfully, but these errors were encountered: