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

Crash when measuring with 'Min Distance' and distance is 0 #288

Open
Jopie01 opened this issue Aug 2, 2024 · 10 comments
Open

Crash when measuring with 'Min Distance' and distance is 0 #288

Jopie01 opened this issue Aug 2, 2024 · 10 comments
Assignees
Labels
Milestone

Comments

@Jopie01
Copy link

Jopie01 commented Aug 2, 2024

I use Mayo to open a STEP file and do some measurements and sometimes when I measure for example two faces which are parallel and exactly (I mean exactly) on each other then Mayo crashes with

terminate called after throwing an instance of 'Standard_ConstructionError'

Mayo can also crash when you have a face and select an edge which lies on that face and therefore the measurement is also exactly zero. Manually offsetting just a little bit (0.000001) shows 0 and doesn't crash. The quality of the BREP mesh is 'Normal'

@HuguesDelorme
Copy link
Member

HuguesDelorme commented Aug 2, 2024

Thanks for reporting, that's interesting to fix.
Do you have some file you can share to reproduce the problem?
Otherwise I can probably write a unit test to check this

@HuguesDelorme HuguesDelorme self-assigned this Aug 2, 2024
@HuguesDelorme HuguesDelorme added this to the version/0.9.0 milestone Aug 2, 2024
@HuguesDelorme
Copy link
Member

Reproduced a crash with this unit test:

void TestMeasure::BRepMinDistance_TwoConfusedFaces_test()
{
    const TopoDS_Face face1 = BRepBuilderAPI_MakeFace(gp_Pln(gp::XOY()));
    const TopoDS_Face face2 = BRepBuilderAPI_MakeFace(gp_Pln(gp::XOY()));
    try {
        const MeasureDistance minDist = MeasureToolBRep::brepMinDistance(face1, face2);
        QCOMPARE(minDist.value.value(), 0.);
    } catch (const IMeasureError& err) {
        qDebug() << QString::fromUtf8(err.message().data(), err.message().length());
    }
}

In this case this is not crashing because of Standard_ConstructionError exception but by Mayo: after distance computation it checks if the OpenCascade tool used is in valid state(ie BRepExtrema_DistShapeShape::IsDone())
If not then it throws an application-level exception(IMeasureError here)

Anyway Mayo should take care of exceptions here and report any error instead of crashing

@Jopie01
Copy link
Author

Jopie01 commented Aug 2, 2024

Below a test file. Rename the extension .txt to .step because it's a STEP file but the extension is not supported here.

test.txt

Selecting two faces will work as long as they don't overlap, but selecting a face and an edge crashes.

@HuguesDelorme
Copy link
Member

@Jopie01
I couldn't reproduce the crash with the test file you provided
However I pushed a change in develop branch to handle any exception thrown by OpenCascade, so this should fix the issue
Let me know how Mayo now behaves on your side

@Jopie01
Copy link
Author

Jopie01 commented Aug 5, 2024

Pulled the changes and rebuilded Mayo. Problem still exists. See attached video.

distance_crash.mp4

The error is still

terminate called after throwing an instance of 'Standard_ConstructionError'

When I open a STEP file, I also see in my terminal

TKOpenGl | Type: Other | ID: 0 | Severity: Medium | Message:
  OpenGl_Window::CreateWindow: window Visual is incomplete: no depth buffer, no stencil buffer

I get the same message when using the AppImage (version 0.8.0) so I don't think it has something to do with this.

So I think I'm also waiting here for the new AppImage to see what that one does. I'm starting to suspect some graphics library which is causing trouble. Which one? No idea.

That Mayo crashes is not a huge problem (I'm just measuring things), but I wish there were an option to disable making a memory dump (is that even possible?). With bigger files this is taking quite some time and the whole PC is frozen.

@HuguesDelorme HuguesDelorme reopened this Aug 6, 2024
@HuguesDelorme
Copy link
Member

Couldn't reproduce this crash on Ubuntu 20.04 with Mayo built from latest develop branch + OpenCascade 7.7.0
#288_test

@HuguesDelorme
Copy link
Member

That would be great if you could provide here the callstack info in the memory dump

@Jopie01
Copy link
Author

Jopie01 commented Aug 7, 2024

That would be great if you could provide here the callstack info in the memory dump

Problem is that I don't have any idea where that memory dump is stored. It just tells me that the program is closed and a memory dump created.

Do you have a clue where that dump possibly is stored?

@HuguesDelorme
Copy link
Member

@Jopie01
There is also that page which might help you:
https://askubuntu.com/questions/1349047/where-do-i-find-core-dump-files-and-how-do-i-view-and-analyze-the-backtrace-st

Try this command:

# Enable core dump files
ulimit -c unlimited

Then try to run Mayo, if it crashes it should create a core file into the same directory from where Mayo was called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants