Giter Site home page Giter Site logo

Comments (6)

refi64 avatar refi64 commented on September 28, 2024

Were you ever able to solve this?

from boost.application.

snikulov avatar snikulov commented on September 28, 2024

@kirbyfan64 could you please confirm this issue on latest master?

from boost.application.

refi64 avatar refi64 commented on September 28, 2024

Looks like it...if I build in debug instead, I get:

Assertion failed: px != 0, file C:\boost_1_65\boost/smart_ptr/shared_ptr.hpp, line 734

I'll check out a debugger for an actual traceback...

from boost.application.

refi64 avatar refi64 commented on September 28, 2024

Traceback:

* thread #4, stop reason = breakpoint 1.3
    frame #0: 0x5887ea40 ucrtbased.dll`abort
    frame #1: 0x588830dd ucrtbased.dll`_get_wide_winmain_command_line + 7549
    frame #2: 0x58882d89 ucrtbased.dll`_get_wide_winmain_command_line + 6697
    frame #3: 0x5888142d ucrtbased.dll`_get_wide_winmain_command_line + 205
    frame #4: 0x588833fa ucrtbased.dll`_wassert + 26
    frame #5: 0x009ce493 simple_server_application.exe`boost::detail::win32::handle_manager::operator void *(void)const  + 579
  * frame #6: 0x009b1484 simple_server_application.exe
    frame #7: 0x009b2234 simple_server_application.exe
    frame #8: 0x009e70be simple_server_application.exe`void boost::thread::yield(void) + 7422
    frame #9: 0x009e6fe0 simple_server_application.exe`void boost::thread::yield(void) + 7200
    frame #10: 0x009e6e8d simple_server_application.exe`void boost::thread::yield(void) + 6861
    frame #11: 0x009e7128 simple_server_application.exe`void boost::thread::yield(void) + 7528
    frame #12: 0x76f48744 kernel32.dll`BaseThreadInitThunk + 36
    frame #13: 0x7797582d ntdll.dll`RtlGetAppContainerNamedObjectPath + 253
    frame #14: 0x779757fd ntdll.dll`RtlGetAppContainerNamedObjectPath + 205

Yes, this sucks, but I can't get lldb to read pdb info, and I'm still trying to get a Clang build working...

from boost.application.

Kojoley avatar Kojoley commented on September 28, 2024

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;
}

from boost.application.

snikulov avatar snikulov commented on September 28, 2024

@kirbyfan64 @AldrichChen Could you please confirm that issue is gone, or provide MCVE for the issue?

Thank you.

P.S.
Example of MCVE here.

from boost.application.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.