View Issue Details

IDProjectCategoryView StatusLast Update
0004258PartDesignBugpublic2020-03-09 16:54
ReporterZolko Assigned To 
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
PlatformFreeCADOSLinux and Windows 
Product Version0.19 
Target Version0.19 
Summary0004258: FreeCAD crashes on "Edit datum" in PartDesign when datum in Part
DescriptionWith datum objects, when used in an App::Part and not in a PartDesign::Body, when using the command "Edit datum" from the contextual menu in PartDesign WB, selecting anything as reference and clicking "OK" crashes FreeCAD.

Happens with the latest FreeCAD AppImage, with an old FreCAD v0.17 and the latest FreeCAD 0.19 for Windows.


In Windows:

"Illegal storage access...
Unhandled Base::Exception caught in GUIApplication::notify
The error message is: Illegal storage access! Please save your work under a new file name and restart the application!"

In Linux:

Program received signal SIGSEGV, Segmentation fault.
#0  /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20) [0x7f972b816f20]
#1  0x7f9705befe74 in PartDesignGui::TaskDlgDatumParameters::accept() from /tmp/.mount_FreeCAjHWTrE/usr/lib/PartDesignGui.so+0xb4
0000002  0x7f972e2ef509 in Gui::TaskView::TaskView::accept() from /tmp/.mount_FreeCAjHWTrE/usr/bin/../lib/libFreeCADGui.so+0x59
0000003  0x7f972bf727b8 in QMetaObject::activate(QObject*, int, int, void**) from /tmp/.mount_FreeCAjHWTrE/usr/bin/../lib/libQt5Core.so.5+0x780
0000004  ...

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19327 (Git)
Build type: Release
Branch: master
Hash: 65c4e1bd11e0820cd1f1d6577d23bf9cdbb54247
Python version: 3.7.3
Qt version: 5.12.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/France (fr_FR)

OS: Ubuntu 18.04.3 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19323 (Git) AppImage
Build type: Release
Branch: master
Hash: 1b198453b8eb6aa2eaca4e4be4b49fee74e9de6e
Python version: 3.8.1
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United Kingdom (en_GB)

OS: Ubuntu 18.04.3 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13541 (Git) AppImage
Build type: None
Branch: releases/FreeCAD-0-17
Hash: 9948ee4f1570df9216862a79705afb367b2c6ffb
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)

Steps To Reproduce
- create a new document
- in Part WB create a Part
- in PartDesign WN create a Body inside the Part
- create 2 datum objects of any type in the Body (for example "DatumPlane" and "DatumLine")
- attach or not, doesn't matter
- move (drag) in the tree from the Body to the Part
- while still in PartDesign WB, right-click on second datum object ("DatumLine") and choose "Edit datum" in the contextual menu
- as first reference choose the first datum object ("DatumPlane")
- choose any attachment mode, even "Deactivated"
- click "OK"

=> FreeCAD crashes

If, instead of the first datum, one uses a sketch, and attaches the datum to something in the sketch, FreeCAD crashes.

When doing the same, but instead of right-click "Edit datum" in the PartDesign WB, one switches to the Part WB, and selects Menu > Attachment..., the exact same dialog appears, and when selecting the exact same objects FreeCAD handles without problems.

In the same way, when clicking on the small button with "..." on the MapMode property of the second datum, the exact same dialog UI apperas, and again FreeCAD handles without problems.

In the same way, when calling Gui.runCommand('Part_EditAttachment') on the selected datum, the same dialog UI comes up and FreeCAD handles without problems.
Additional InformationWhen looking closely at the crash report in Linux:


#0  /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20) [0x7f972b816f20]
#1  0x7f9705befe74 in PartDesignGui::TaskDlgDatumParameters::accept() from .../PartDesignGui.so+0xb4
0000002  0x7f972e2ef509 in Gui::TaskView::TaskView::accept() from .../libFreeCADGui.so+0x59
0000003  0x7f972bf727b8 in QMetaObject::activate(QObject*, int, int, void**) from .../libQt5Core.so.5+0x780
This looks like a GUI/Qt segfault.


** "Edit datum" is defined in src/Mod/PartDesign/Gui/ViewProviderDatum.cpp:

void ViewProviderDatum::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
    QAction* act;
    act = menu->addAction(QObject::tr("Edit datum"), receiver, member);
    act->setData(QVariant((int)ViewProvider::Default));
}


**  setupContextMenu is called from :
    src/Mod/PartDesign/Gui/TaskDatumParameters.cpp:
setupContextMenu{
    assert(ViewProvider);
    parameter  = new TaskDatumParameters(ViewProvider);
    Content.push_back(parameter);
}

** TaskDatumParameters is constructed with:

TaskDatumParameters::TaskDatumParameters(ViewProviderDatum *ViewProvider,QWidget *parent)
    : PartGui::TaskAttacher(ViewProvider, parent, QString::fromLatin1("PartDesign_") + ViewProvider->datumType,
              ViewProvider->datumText + tr(" parameters"))
              
** TaskDlgDatumParameters::accept is defined in
    src/Mod/PartDesign/Gui/TaskDatumParameters.cpp:

    
** TaskDlgDatumParameters is defined in

    src/Mod/PartDesign/Gui/TaskDatumParameters.cpp:
TaskDlgDatumParameters::TaskDlgDatumParameters(ViewProviderDatum *ViewProvider)
    : TaskDlgAttacher(ViewProvider, false)
    
** TaskDlgAttacher is defined in
    src/Mod/Part/Gui/TaskAttacher.cpp
    its constructor calls new TaskAttacher
    
    
** There is a TaskAttacher.ui in
    src/Mod/Part/Gui/TaskAttacher.ui
    where the window widget is called
    PartGui::TaskAttacher
    
    
** There is also a TaskAttachmentEditor.ui in:
    src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.ui
    with the same UI layout, where the window widget is called
    PartDesignGui::TaskDatumParameters
    
    
CONCLUSION: one of these 2 crashes FreeCAD with datum objects in App::Parts when called with "Edit datum" from PartDesign WB. Following the trail: "Edit datum > setupContextMenu > TaskDatumParameters > PartGui::TaskAttacher" , it looks like
src/Mod/Part/Gui/TaskAttacher.ui is the bad one.

ALSO: Since it is possible to edit the attachment of datum objects - and any object - with
>>> Gui.runCommand('Part_EditAttachment')
from the python console, and 'Part_EditAttachment' is defined in src/Mod/Part/AttachmentEditor/Commands.py, it looks like src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.ui is the good one.

Visually, both seem identical, except that in
    src/Mod/Part/Gui/TaskAttacher.ui the input fields are of type Gui::QuantitySpinbox and Gui::PrefQuantitySpinBox,
while in
    src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.ui they're all Gui::InputField
    


This problem seems to have been known before in src/Mod/PartDesign/Gui/TaskDatumParameters.cpp:

****
    //we need to add the copied features to the body after the command action, as otherwise FreeCAD crashes unexplainably
    for(auto obj : copies) {
        if (pcActiveBody)
            pcActiveBody->addObject(obj);
        else if (pcActivePart)
            pcActivePart->addObject(obj);
    }
****
Tags#pending-forum, attachment, datum line, GUI, Part, Part Design
FreeCAD InformationOS: Ubuntu 18.04.3 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19323 (Git) AppImage
Build type: Release
Branch: master
Hash: 1b198453b8eb6aa2eaca4e4be4b49fee74e9de6e
Python version: 3.8.1
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United Kingdom (en_GB)

Activities

Zolko

2020-01-27 14:19

reporter   ~0014118

Last edited: 2020-01-27 14:21

View 2 revisions

I don't succeed in uploading the 2 screenshots of the 2 QtDesigner UI files

openBrain

2020-01-27 18:48

developer   ~0014122

@Zolko : I don't think using a Datum object out of a PartDesign Body is an expected usage. Though a crash is always good to avoid.
Anyway, please open a topic in the forum first to discuss your issue according our bug reporting guidelines (https://forum.freecadweb.org/viewtopic.php?f=3&t=5236). Thx

Zolko

2020-01-28 09:06

reporter   ~0014124

@openBrain : please define "expected usage". Because using datum objects outside the PartDesign WB is clearly something many users are doing and asking-for even more: https://forum.freecadweb.org/viewtopic.php?f=8&t=42759

openBrain

2020-01-28 16:50

developer   ~0014125

@Zolko : please open a forum topic so we can further discuss that. Basically it means that it hasn't been foreseen as a usage (hence the Datum are PartDesign features and thus shall live inside a Body).

Kunda1

2020-02-05 16:11

administrator   ~0014140

Forum thread: https://forum.freecadweb.org/viewtopic.php?f=3&t=42750
Zolko, next time please use code tags on the ticket for more efficient readability. I've added
 them. Thanks for the ticket.

Kunda1

2020-02-10 22:07

administrator   ~0014145

My bad, MantisBT was missing it's bbcode toolbar. Cancel clear regarding 0004258:0014140

openBrain

2020-03-09 11:02

developer   ~0014218

@Zolko : may you please test and confirm that wmayer's change fixes the issue ? Thx

Zolko

2020-03-09 12:03

reporter   ~0014219

@openBrain : I tested with latest AppImage build and yes, the "Edit Datum" crash doesn't happen again. I think we can close the issue, thank-you very much.

OS: Ubuntu 18.04.3 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19955 (Git) AppImage
Build type: Release
Branch: master
Hash: fd907d6d9789f71007b8d0177d167f1de82629b8
Python version: 3.8.2
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United Kingdom (en_GB)

Zolko

2020-03-09 12:23

reporter   ~0014220

Actually, was fixed between 0.19-19405 and 0.19-19443, consistent with:

"wmayer committed on 30 Jan"

Related Changesets

FreeCAD: master f70a267d

2020-01-30 09:07:17

wmayer

Details Diff
issue 0004258: FreeCAD crashes on "Edit datum" in PartDesign when datum in Part [skip-ci] Affected Issues
0004258
mod - src/Mod/PartDesign/Gui/TaskDatumParameters.cpp Diff File

Issue History

Date Modified Username Field Change
2020-01-27 14:16 Zolko New Issue
2020-01-27 14:16 Zolko Tag Attached: attachment
2020-01-27 14:16 Zolko Tag Attached: datum line
2020-01-27 14:16 Zolko Tag Attached: GUI
2020-01-27 14:16 Zolko Tag Attached: Part
2020-01-27 14:16 Zolko Tag Attached: Part Design
2020-01-27 14:19 Zolko Note Added: 0014118
2020-01-27 14:21 Zolko Note Edited: 0014118 View Revisions
2020-01-27 18:48 openBrain Status new => feedback
2020-01-27 18:48 openBrain Note Added: 0014122
2020-01-27 18:48 openBrain Tag Attached: #post-to-forum
2020-01-27 19:03 openBrain Priority high => normal
2020-01-28 09:06 Zolko Note Added: 0014124
2020-01-28 09:06 Zolko Status feedback => new
2020-01-28 16:50 openBrain Note Added: 0014125
2020-02-05 16:11 Kunda1 Note Added: 0014140
2020-02-05 16:11 Kunda1 Tag Detached: #post-to-forum
2020-02-05 16:11 Kunda1 Tag Attached: #pending-forum
2020-02-05 16:11 Kunda1 Assigned To => Kunda1
2020-02-05 16:11 Kunda1 Status new => assigned
2020-02-05 16:12 Kunda1 Assigned To Kunda1 =>
2020-02-05 16:12 Kunda1 Status assigned => acknowledged
2020-02-05 16:13 Kunda1 Description Updated View Revisions
2020-02-05 16:18 Kunda1 Description Updated View Revisions
2020-02-05 16:18 Kunda1 Additional Information Updated View Revisions
2020-02-10 22:07 Kunda1 Target Version => 0.19
2020-02-10 22:07 Kunda1 Note Added: 0014145
2020-03-02 20:16 wmayer Changeset attached => FreeCAD master f70a267d
2020-03-09 11:02 openBrain Note Added: 0014218
2020-03-09 12:03 Zolko Note Added: 0014219
2020-03-09 12:23 Zolko Note Added: 0014220
2020-03-09 16:54 openBrain Status acknowledged => closed
2020-03-09 16:54 openBrain Resolution open => fixed