Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing property Object1 or Object2 of fixed joint causing crash #13912

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Jiri-Macha
Copy link
Contributor

FreeCAD is crashing if the 'Object' property of fixed joint (Assembly/Joints/Fixed/Joint Connector 1/Object1 or Assembly/Joints/Fixed/Joint Connector 2/Object2) is manually removed.

Steps to reproduce:

  • make simple Assembly e.g. of two cubes with Fixed joint
  • Select Fixed joint in the tree and go-to property 'Data' tab
  • Select 'Object1' or 'Object2' of the 'Joint Connector 1' or 'Joint Connector 2'
    and remove this reference
  • click by your pointing device (mouse) to the arbitrary other property

FreeCAD will crash here because the call App::DocumentObject* obj = getObjFromNameProp(joint, propObjName, propPartName); will return NULL pointer.

This problem is similar to the 4b5d079.

FreeCAD is crashing if the 'Object'
property of fixed joint (Assembly/Joints/Fixed/Joint Connector 1/Object1 or
Assembly/Joints/Fixed/Joint Connector 2/Object2) is manually removed.

Steps to reproduce:

 - make simple Assembly e.g. of two cubes with Fixed joint
 - Select Fixed joint in the tree and go-to property 'Data' tab
 - Select 'Object1' or 'Object2' of the 'Joint Connector 1' or 'Joint Connector 2'
   and remove this reference
 - click by your pointing device (mouse) to the arbitrary other property

The FreeCAD will crash here because the call
App::DocumentObject* obj = getObjFromNameProp(joint, propObjName, propPartName);
will return NULL pointer.

This problem is similar to the
4b5d079.
The warning message text is not describing two cases which can happen,
but only one - property of specific joint.
@github-actions github-actions bot added the WB Assembly Related to the Integrated Assembly Workbench label May 9, 2024
@FEA-eng
Copy link
Contributor

FEA-eng commented May 13, 2024

There's no linked issue so I don't know on which OS the crash occurs but I can't reproduce it on Windows (with the AssemblyExample.FCStd file). Are you using Linux?

OS: Windows 10 build 19045
Word size of FreeCAD: 64-bit
Version: 0.22.0dev.37213 (Git)
Build type: Release
Branch: main
Hash: 20e7deb86a8c6c2cd2378f09f8313760933f3a5c
Python 3.11.9, Qt 5.15.13, Coin 4.0.2, Vtk 9.2.6, OCC 7.7.2
Locale: Polish/Poland (pl_PL)

@Jiri-Macha
Copy link
Contributor Author

Jiri-Macha commented May 13, 2024

Yes please. My system is Gentoo Linux (with Sway tiling Wayland compositor) - almost HEAD.
I just rebuild FreeCAD from the 8fcaaed to test it once again,
this time I made the test with AssemblyExample.FCStd and the result was the same - crash - see also the
screenshot below. It is a bit surprise to me that it works on Windows. I would like
to know what is returned after the call of getObjFromNameProp(joint, propObjName, propPartName)
in such use case (after removal of Object of Joint Connector). I might explore it later on this
platform as well.

Based on your observation (inconsistency between platforms Windows/Linux) and the fact that the same
calls (of function getLinkObjFromProp and getObjFromNameProp) are made also in the AssemblyObject::getRackPinionMarkers function and return values (part1 and obj1) are there also not checked, I think, there are some more defects there, and we will need to patch it also in the near future.

In any case, this patch (pull request) is helping in my use case (Linux + Wayland compositor), is ensuring
validation of returned value and as such should not have negative side effects.

2024-05-13 203536

@FEA-eng
Copy link
Contributor

FEA-eng commented May 20, 2024

@PaddleStroke Can you have a look at this?

@PaddleStroke
Copy link
Contributor

I see no crash on my side either (windows) but the this PR can be merged as it just adds a protection it's totally acceptable.

Similar problems:

07c6df6
and
4b5d079

were causing real crashes (Linux + Sway Wayland compositor) when
Fixed joint type was used.

This patch tries to avoid the same situation, but now for the
rack pinion joint type.

The returned pointer value (part1 and obj1) can get NULL pointer value
and is used in the code:

    if (obj1->getNameInDocument() != part1->getNameInDocument()) { ....

a few lines later.
@Jiri-Macha
Copy link
Contributor Author

I just pushed one more patch for the rack pinion joint where the crash could also occur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WB Assembly Related to the Integrated Assembly Workbench
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants