View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000659 | FreeCAD | Bug | public | 2012-04-02 02:49 | 2012-04-02 17:02 |
Reporter | chinasaurli | Assigned To | |||
Priority | normal | Severity | crash | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Fixed in Version | 0.13 | ||||
Summary | 0000659: SIGABRT on startup in boost::program_options (Boost 1.49) | ||||
Description | I'm trying to build the latest source on Mac OS 10.7 using cmake. Eventually got through the build but FreeCAD crashes on startup. The first time I run it through gdb I get a bunch of warnings about it not finding SoQt object files (not sure why it is looking for them under a ".lax" directory on Mac...). But I don't think that causes the crash that's just a debugging issue. Here's the backtrace on a rerun from that point: (gdb) run The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /Users/peterli/Downloads/freecad-build/bin/FreeCAD Reading symbols for shared libraries . done FreeCAD(65466,0x7fff7d144960) malloc: *** error for object 0x7fff7dcc3860: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug Program received signal SIGABRT, Aborted. 0x00007fff8faddce2 in __pthread_kill () (gdb) bt #0 0x00007fff8faddce2 in __pthread_kill () #1 0x00007fff8f6cd7d2 in pthread_kill () 0000002 0x00007fff8f6bea7a in abort () 0000003 0x00007fff8f71d84c in free () 0000004 0x0000000100cef41f in boost::program_options::basic_option<char>::~basic_option () 0000005 0x0000000105308c33 in std::__copy_aux<boost::program_options::detail::basic_config_file_iterator<char>, std::back_insert_iterator<std::vector<boost::program_options::basic_option<char>, std::allocator<boost::program_options::basic_option<char> > > > > () 0000006 0x0000000105308d45 in std::__copy_normal<false, false>::__copy_n<boost::program_options::detail::basic_config_file_iterator<char>, std::back_insert_iterator<std::vector<boost::program_options::basic_option<char>, std::allocator<boost::program_options::basic_option<char> > > > > () 0000007 0x0000000105308e65 in std::copy<boost::program_options::detail::basic_config_file_iterator<char>, std::back_insert_iterator<std::vector<boost::program_options::basic_option<char>, std::allocator<boost::program_options::basic_option<char> > > > > () 0000008 0x0000000105305965 in boost::program_options::parse_config_file<char> () 0000009 0x0000000100cdf350 in App::Application::ParseOptions () 0000010 0x0000000100cda8f4 in App::Application::initConfig () 0000011 0x0000000100cda0f2 in App::Application::init () 0000012 0x00000001000088b2 in main () (gdb) So seems to be an issue with these lines from App/Application.cpp: std::ifstream ifs("FreeCAD.cfg"); store(parse_config_file(ifs, config_file_options), vm); I've seen in other people's gdb runs that on the first run FreeCAD is supposed to detect that it is missing the config file and generate one, but I don't even seem to get to that point. I wonder if it's an issue with the new Boost (1.49). I'm going to keep looking into it, but hoping someone already knows what's up. | ||||
Tags | No tags attached. | ||||
FreeCAD Information | |||||
|
It's definitely something with boost 1.49 because I recently setup a test system running boost 1.48 on it and there is no such problem. Note, the FreeCAD.cfg file has nothing to do with the user config. The FreeCAD.cfg file can contain some command line parameters which boost parses at startup. However, usually this file doesn't exist and maybe boost 1.49 doesn't like this. What happens if you simply comment out the lines: std::ifstream ifs("FreeCAD.cfg"); store(parse_config_file(ifs, config_file_options), vm); notify(vm); |
|
I tried commenting out the first two lines but not the notify; I thought I still wanted the notify for the command line parser just above. Without those two lines, it still crashed on one of the options_description constructors. I recompiled in debug mode so now I should have more luck tracking things down, but the problem seems a little deeper than I originally thought. |
|
Okay, well commenting out the entire call to App::Application::ParseOptions allows FreeCAD to start, so nice to know the build isn't completely broken. I haven't been successful avoiding this crash by commenting out any subsection of ParseOptions so far. The SIGABRT just moves to a different line. Is program_options a header-only library or is it compiled? Maybe there's something wrong with my boost binary? |
|
Ah, okay my mistake; after commenting out the parse_config_file the crash moves to the options_description DESTRUCTOR, not constructor. If I put a return in here: --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -1485,6 +1485,8 @@ void Application::ParseOptions(int ac, char ** av) boost::program_options::positional_options_description p; p.add("input-file", -1); + return; + variables_map vm; try { store( boost::program_options::command_line_parser(ac, av). It still crashes, so seems like ultimately the problem is probably the destructor freeing something wonky. |
|
Suspect the problem is here: options_description cmdline_options; cmdline_options.add(generic).add(config).add(hidden); boost::program_options::options_description config_file_options; config_file_options.add(config).add(hidden); boost::program_options::options_description visible("Allowed options"); visible.add(generic).add(config); Because options_description generic, config, hidden are shared across cmdline_options, config_file_options, visible, so get freed multiple times in destructor. Testing now. |
|
Hmm, but this usage is in the boost docs: http://www.boost.org/doc/libs/1_49_0/doc/html/program_options/howto.html So if this is the problem it's a boost bug. |
|
Okay problem is there but it's because cmdline_options, etc. are called without a caption string. Patch coming. |
|
Okay, that fixed the options_description but parse_config_file is still an issue now. |
|
This now works for me, but I'm not sure if ifstream#good was the right way to check things in the case that FreeCAD.cfg actually does exist. --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -1473,10 +1473,11 @@ void Application::ParseOptions(int ac, char ** av) // ("display", boost::program_options::value< string >(), "set the X-Se // ; - options_description cmdline_options; + options_description cmdline_options("Command-line options"); cmdline_options.add(generic).add(config).add(hidden); - boost::program_options::options_description config_file_options; + + boost::program_options::options_description config_file_options("Config"); config_file_options.add(config).add(hidden); boost::program_options::options_description visible("Allowed options"); @@ -1491,7 +1492,10 @@ void Application::ParseOptions(int ac, char ** av) options(cmdline_options).positional(p).extra_parser(customSyntax std::ifstream ifs("FreeCAD.cfg"); - store(parse_config_file(ifs, config_file_options), vm); + + // NOT SURE IF THIS IS THE RIGHT CHECK + if (ifs.good()) store(parse_config_file(ifs, config_file_options), vm); + notify(vm); } catch (const std::exception& e) { |
|
You can also write "if (ifs) ..." because the C++ stream class implements a bool operator which internally uses good() (or maybe another function). |
|
Patch applied in git 23259833a1d44fc991e40c861fd485110e21ca7d |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-04-02 02:49 | chinasaurli | New Issue | |
2012-04-02 05:37 | wmayer | Note Added: 0001845 | |
2012-04-02 13:41 | chinasaurli | Note Added: 0001853 | |
2012-04-02 14:03 | chinasaurli | Note Added: 0001855 | |
2012-04-02 14:15 | chinasaurli | Note Added: 0001856 | |
2012-04-02 14:18 | chinasaurli | Note Added: 0001857 | |
2012-04-02 14:23 | chinasaurli | Note Added: 0001858 | |
2012-04-02 14:39 | chinasaurli | Note Added: 0001859 | |
2012-04-02 14:44 | chinasaurli | Note Added: 0001860 | |
2012-04-02 15:03 | chinasaurli | Note Added: 0001861 | |
2012-04-02 17:01 | wmayer | Note Added: 0001863 | |
2012-04-02 17:02 | wmayer | Note Added: 0001864 | |
2012-04-02 17:02 | wmayer | Status | new => closed |
2012-04-02 17:02 | wmayer | Resolution | open => fixed |
2012-04-02 17:02 | wmayer | Fixed in Version | => 0.13 |