Project

General

Profile

std::bad_alloc error when linking to some libraries (Pylon SDK)

Added by kbarni kbarni about 10 years ago

I have an industrial camera linked to my computer and I would like to create a Wt application to remotely acess its image.

I already wrote the Qt version of my program, which works well. Basler provides a well written SDK for the camera (Pylon SDK).

When I try to link my program to the SDK (add -lpylonbase to the project), the program still runs, but I get an error when I try to connect to this server: Wt: fatal error: std::bad_alloc and WebController: Removing session [session name]. The webpage displays a similar error message.

I don't have any code accessing the camera, it's only linked to the library.

Does anybody have some idea, how can I debug/correct this error?

In fact when (and why) is this linked library called?

Is there a possibility to create a unique thread for the camera (let's say a QThread), which is later accessed by the different Wt sessions?

Any help is much appreciated!


Replies (3)

RE: std::bad_alloc error when linking to some libraries (Pylon SDK) - Added by Koen Deforche about 10 years ago

There are many possible reasons. I would try to catch the problem in a debugger ('catch throw' in gdb) or run with valgrind to see what's the origin.

RE: std::bad_alloc error when linking to some libraries (Pylon SDK) - Added by kbarni kbarni about 10 years ago

Thanks for the idea! I ran GDB, and I caught the exception at the following location: WebController::handleRequest():713 -> WebSession::handleRequest():1363 -> WebSession::init():367 -> WEnvironment::setUserAgent():373 -> WEnvironment::agentIsBot():470

The code is: return regexMatchAny(agent,botList*); the value of the agent variable is*"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0"_ and the botlist_ seems normal, too (".Googlebot.",".msnbot."...). In the function regexpMatchAny it crashes at the first element (".Googlebot.").

I wonder if the camera library I'm using messes up something in the memory? (in this case I'm out of luck as it's closed source) I wonder why is it loaded anyway if it isn't used.

Here is the full callstack:

0   __cxa_throw /usr/lib/x86_64-linux-gnu/libstdc++.so.6        0x7ffff57f2a30  
1   operator new(unsigned long) /usr/lib/x86_64-linux-gnu/libstdc++.so.6        0x7ffff57f2f8d  
2   allocate    new_allocator.h 104 0x7ffff773293b  
3   _M_allocate stl_vector.h    168 0x7ffff773293b  
4   std::vector<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string>>>::_M_fill_insert   vector.tcc  483 0x7ffff773293b  
5   insert  stl_vector.h    1024    0x7ffff7734a1d  
6   set_size    match_results.hpp   505 0x7ffff7734a1d  
7   boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string>>>, boost::regex_traits<char, boost::cpp_regex_traits<char>>>::match_imp   perl_matcher_common.hpp 203 0x7ffff7734a1d  
8   match   perl_matcher_common.hpp 182 0x7ffff773099f  
9   regex_match<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string>>>, char, boost::regex_traits<char>>  regex_match.hpp 50  0x7ffff773099f  
10  regex_match<std::char_traits<char>, std::allocator<char>, char, boost::regex_traits<char>>  regex_match.hpp 100 0x7ffff773099f  
11  Wt::WRegExp::exactMatch WRegExp.C   90  0x7ffff773099f  
12  (anonymous namespace)::regexMatchAny    Configuration.C 51  0x7ffff790f75c  
13  Wt::Configuration::agentIsBot   Configuration.C 470 0x7ffff7910c4f  
14  Wt::WEnvironment::setUserAgent  WEnvironment.C  373 0x7ffff7668769  
15  Wt::WEnvironment::init  WEnvironment.C  105 0x7ffff7669f8a  
16  Wt::WebSession::init    WebSession.C    367 0x7ffff793e160  
17  Wt::WebSession::handleRequest   WebSession.C    1363    0x7ffff794297e  
18  Wt::WebController::handleRequest    WebController.C 713 0x7ffff79340c6  
19  operator()  mem_fn_template.hpp 165 0x7ffff6f7af9f  
20  operator()<boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list0>   bind.hpp    313 0x7ffff6f7af9f  
21  operator()  bind_template.hpp   20  0x7ffff6f7af9f  
22  asio_handler_invoke<boost::_bi::bind_t<void, boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list2<boost::_bi::value<Wt::WebController*>, boost::_bi::value<http::server::HTTPRequest*>>>>  handler_invoke_hook.hpp 64  0x7ffff6f7af9f  
23  invoke<boost::_bi::bind_t<void, boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list2<boost::_bi::value<Wt::WebController*>, boost::_bi::value<http::server::HTTPRequest*>>>, boost::_bi::bind_t<void, boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list2<boost::_bi::value<Wt::WebController*>, boost::_bi::value<http::server::HTTPRequest*>>>>    handler_invoke_helpers.hpp  37  0x7ffff6f7af9f  
24  boost::asio::detail::completion_handler<boost::_bi::bind_t<void, boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list2<boost::_bi::value<Wt::WebController*>, boost::_bi::value<http::server::HTTPRequest*>>>>::do_complete completion_handler.hpp  68  0x7ffff6f7af9f  
25  complete    task_io_service_operation.hpp   37  0x7ffff76b24bf  
26  do_run_one  task_io_service.ipp 384 0x7ffff76b24bf  
27  boost::asio::detail::task_io_service::run   task_io_service.ipp 153 0x7ffff76b24bf  
28  run io_service.ipp  59  0x7ffff76ae5dc  
29  Wt::WIOService::run WIOService.C    180 0x7ffff76ae5dc  
30  ??  /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.54.0     0x7ffff6c92a4a  
31  start_thread        312 0x7ffff5aa0182  
32  clone       111 0x7ffff52b347d  

Do you have any idea where to go next?

RE: std::bad_alloc error when linking to some libraries (Pylon SDK) - Added by Wim Dumon about 10 years ago

Could it be that the C or C library used to compile the camera library is incompatible with the one you use to compile Wt?

Maybe valgrind tells you something more?

BR,

Wim.

    (1-3/3)