View Issue Details

IDProjectCategoryView StatusLast Update
0003424FreeCADBugpublic2018-04-10 08:57
ReporterprogvalAssigned Towmayer 
PrioritynormalSeveritycrashReproducibilityhave not tried
Status closedResolutionfixed 
PlatformLinuxOSDebianOS Version9
Product Version0.17 
Target VersionFixed in Version0.17 
Summary0003424: "basic_string::_M_construct null not valid" when opening a v0.16 project with v0.17
DescriptionHi,

I recently compiled FreeCAD from the git tag "v0.17". When loading one of my projects (not all of them), I get the following error in the console:


Traceback (most recent call last):
  File "<string>", line 1, in <module>
<type 'exceptions.IOError'>: Invalid project file /home/val/cad/ens/ens.fcstd: basic_string::_M_construct 
null not valid
Steps To ReproduceOpen FreeCAD
Open the file attached to this issue.
-> Crash
Additional InformationUsing gdb, I managed to get the following backtrace (using "catch throw"):


#0  0x00007fffece2226d in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007fffece4a8ef in std::__throw_logic_error(char const*) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6

0000002  0x00007ffff5a9eda7 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> 
>::_M_construct<char const*> (this=0x7fffffff9f00, __beg=0x0, 
    __end=0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>) at /usr/include/c++/6/bits/basic_string.tcc:212

0000003  0x00007fffeceb33cc in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> 
>::basic_string(char const*, std::allocator<char> const&) ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
0000004  0x00007ffff5b36024 in App::FeaturePythonImp::onChanged (this=0x5555594f70e0, prop=0x7fffffffa360) 
at /home/freecad/FreeCAD/src/App/FeaturePython.cpp:152
0000005  0x00007fff8f2642a0 in App::FeaturePythonT<Part::Part2DObject>::onChanged (this=0x5555594f3da0, 
prop=0x7fffffffa360) at /home/freecad/FreeCAD/src/App/FeaturePython.h:202
0000006  0x00007ffff5b74965 in App::Property::hasSetValue (this=0x7fffffffa360) at /home/freecad/FreeCAD/src/App/Property.cpp:125

0000007  0x00007ffff5b8da2d in App::PropertyLinkSub::setValue (this=0x7fffffffa360, lValue=0x0, SubList=std::vector 
of length 0, capacity 0)
    at /home/freecad/FreeCAD/src/App/PropertyLinks.cpp:473
0000008  0x00007ffff5b8effd in App::PropertyLinkSub::Restore (this=0x7fffffffa360, reader=...) at /home/freecad/FreeCAD/src/App/PropertyLinks.cpp:610

0000009  0x00007fff8f262f35 in Part::Part2DObject::handleChangedPropertyType (this=0x5555594f3da0, reader=..., 
TypeName=0x5555598fe180 "\260\032dYUU", prop=0x5555594f40b8)
    at /home/freecad/FreeCAD/src/Mod/Part/App/Part2DObject.cpp:231
0000010 0x00007ffff5b6861a in App::DynamicProperty::Restore (this=0x5555594f8090, reader=...) at /home/freecad/FreeCAD/src/App/DynamicProperty.cpp:442

0000011 0x00007fff8f2641a8 in App::FeaturePythonT<Part::Part2DObject>::Restore (this=0x5555594f3da0, 
reader=...) at /home/freecad/FreeCAD/src/App/FeaturePython.h:178
0000012 0x00007ffff5a71fc7 in App::Document::readObjects (this=0x55555750edd0, reader=...) at /home/freecad/FreeCAD/src/App/Document.cpp:1533

0000013 0x00007ffff5a7104b in App::Document::Restore (this=0x55555750edd0, reader=...) at /home/freecad/FreeCAD/src/App/Document.cpp:1402

0000014 0x00007ffff5a738a3 in App::Document::restore (this=0x55555750edd0) at /home/freecad/FreeCAD/src/App/Document.cpp:1782

0000015 0x00007ffff5bd2418 in App::Application::openDocument (this=0x5555559096c0, FileName=0x555555d13e10 
"/home/val/cad/ens/ens.fcstd") at /home/freecad/FreeCAD/src/App/Application.cpp:526
0000016 0x00007ffff5bfa863 in App::Application::sOpenDocument (args=0x7fffde388410) at /home/freecad/FreeCAD/src/App/ApplicationPy.cpp:203

0000017 0x00007ffff4cae091 in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
0000018 0x00007ffff4e1529c in PyEval_EvalCodeEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
0000019 0x00007ffff4ca59c9 in PyEval_EvalCode () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
0000020 0x00007ffff4d5d196 in PyRun_StringFlags () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
0000021 0x00007ffff5322662 in Base::InterpreterSingleton::runString[abi:cxx11](char const*) (this=0x5555557cf180, 
sCmd=0x555557508c18 "FreeCAD.open(u\"/home/val/cad/ens/ens.fcstd\")")
    at /home/freecad/FreeCAD/src/Base/Interpreter.cpp:232
0000022 0x00007ffff6734966 in Gui::Command::doCommand (eType=Gui::Command::App, sCmd=0x7ffff6b4b605 "%s.open(u\"%s\")") 
at /home/freecad/FreeCAD/src/Gui/Command.cpp:475
0000023 0x00007ffff66909b7 in Gui::Application::open (this=0x7fffffffcf40, FileName=0x555557509ca8 "/home/val/cad/ens/ens.fcstd", 
Module=0x55555758d2b8 "FreeCAD")
    at /home/freecad/FreeCAD/src/Gui/Application.cpp:513
0000024 0x00007ffff672b87d in Gui::RecentFilesAction::activateFile (this=0x555557242d30, id=0) at /home/freecad/FreeCAD/src/Gui/Action.cpp:731

0000025 0x00007ffff6750839 in StdCmdRecentFiles::activated (this=0x555555cdc510, iMsg=0) at /home/freecad/FreeCAD/src/Gui/CommandStd.cpp:160

0000026 0x00007ffff67340c8 in Gui::Command::invoke (this=0x555555cdc510, i=0) at /home/freecad/FreeCAD/src/Gui/Command.cpp:300

0000027 0x00007ffff6728efe in Gui::ActionGroup::onActivated (this=0x555557242d30, a=0x555557208000) at /home/freecad/FreeCAD/src/Gui/Action.cpp:352

0000028 0x00007ffff672d2e4 in Gui::ActionGroup::qt_static_metacall (_o=0x555557242d30, _c=QMetaObject::InvokeMetaMethod, 
_id=2, _a=0x7fffffffb8e0)
    at /home/freecad/FreeCAD/build/src/Gui/moc_Action.cpp:130
0000029 0x00007fffedc53660 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4

0000030 0x00007fffee701f7f in QActionGroup::triggered(QAction*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4

0000031 0x00007fffee70202f in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000032 0x00007fffedc53660 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4

0000033 0x00007fffee6ff672 in QAction::triggered(bool) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000034 0x00007fffee7009d3 in QAction::activate(QAction::ActionEvent) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4

0000035 0x00007fffeeb5d3cd in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000036 0x00007fffeeb61839 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000037 0x00007fffee75be80 in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000038 0x00007fffeeb65a8b in QMenu::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#39 0x00007fffee70554c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4

#40 0x00007fffee70dca7 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4

0000041 0x00007ffff670255f in Gui::GUIApplication::notify (this=0x7fffffffd210, receiver=0x5555572088e0, 
event=0x7fffffffc2d0) at /home/freecad/FreeCAD/src/Gui/GuiApplication.cpp:91
0000042 0x00007fffedc3ef1d in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4

0000043 0x00007fffee70bccb in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, 
QWidget**, QPointer<QWidget>&, bool) ()
   from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000044 0x00007fffee78742d in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000045 0x00007fffee785b5c in QApplication::x11ProcessEvent(_XEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4

0000046 0x00007fffee7af502 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000047 0x00007fffe51d47f7 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
0000048 0x00007fffe51d4a60 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
0000049 0x00007fffe51d4b0c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
0000050 0x00007fffedc6f854 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) 
() from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
0000051 0x00007fffee7af5d6 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
0000052 0x00007fffedc3d7ef in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from 
/usr/lib/x86_64-linux-gnu/libQtCore.so.4
0000053 0x00007fffedc3db55 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4

0000054 0x00007fffedc43bd9 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4

0000055 0x00007ffff66992b2 in Gui::Application::runApplication () at /home/freecad/FreeCAD/src/Gui/Application.cpp:1902

0000056 0x000055555555c569 in main (argc=1, argv=0x7fffffffe0e8) at /home/freecad/FreeCAD/src/Main/MainGui.cpp:261



Here is the culprit function (frame 0000004, /home/freecad/FreeCAD/src/App/FeaturePython.cpp:152):


void FeaturePythonImp::onChanged(const Property* prop)
{
    ///// Redacted for conciseness
                    Py::Callable method(feature.getAttr(std::string("onChanged")));
                    Py::Tuple args(2);
                    args.setItem(0, Py::Object(object->getPyObject(), true));
                    std::string prop_name = object->getPropertyName(prop); ////// This is the line 
raising the error
                    args.setItem(1, Py::String(prop_name));
                    method.apply(args);
                }
            }
        }
    }
    ///// Redacted for conciseness
}


I did some looking around, and I believe that object->getPropertyName(prop) returns NULL because of this code:


const char* PropertyData::getName(OffsetBase offsetBase,const Property* prop) const
{
  const PropertyData::PropertySpec* Spec = findProperty(offsetBase,prop);

  if(Spec)
    return Spec->Name;
  else
    return 0;


and I believe that Spec is NULL because when using gcc in frame 0000004 (App::FeaturePythonImp::onChanged at /home/freecad/FreeCAD/src/App/FeaturePython.cpp:152), I get this:


(gdb) p prop->father->propertyData
$9 = {propertyData = std::vector of length 0, capacity 0, parentPropertyData = 0x0}
TagsNo tags attached.

Activities

progval

2018-04-09 21:12

reporter  

ens.fcstd (56,812 bytes)

wmayer

2018-04-10 08:57

administrator   ~0011138

Thanks for this very good bug report!

Fixed with:
https://github.com/FreeCAD/FreeCAD/commit/aa0f6b54d497eb810cc2774fa01ac0bb0408541a

Issue History

Date Modified Username Field Change
2018-04-09 21:12 progval New Issue
2018-04-09 21:12 progval File Added: ens.fcstd
2018-04-10 08:57 wmayer Assigned To => wmayer
2018-04-10 08:57 wmayer Status new => closed
2018-04-10 08:57 wmayer Resolution open => fixed
2018-04-10 08:57 wmayer Fixed in Version => 0.17
2018-04-10 08:57 wmayer Note Added: 0011138