-
Notifications
You must be signed in to change notification settings - Fork 294
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
Graceful exit on broke step file #1521
Comments
I tried loading your step directly via CQ and nothing crashes, but I do get an infinite loop it seems. You'll have to raise an issue with OCCT I'm afraid. Is the STEP actually malicious? |
Strange, OCCT Draw shows "Could not read file BROKEN_FILE.step , abandon" this corresponds to Edit: Ignore this comment. My mistake in testing (typo). Actually I do get the same |
Interesting, on win I get an infinite loop with 7.7.1 and a silent crash with 7.7.2. |
I can reproduce the crash on linux with CQ and 7.7.2. OCCT Draw does not crash; it does report ERR messages in the output (7.7.2):
The same ERR messages are printed with CQ with: from OCP.Message import Message, Message_Gravity
for printer in Message.DefaultMessenger_s().Printers():
printer.SetTraceLevel(Message_Gravity.Message_Info) |
I wouldn't call STEP file malicious. We did remove a line or two by hand to simulate the broken file, though. |
@lorenzncode interesting. I checked with draw from 7.5 I do get an infinite loop of sorts. Draw from 7.8 works fine (I don't have 7.7.2 at hand). Looking quickly at the code of OCCT I was not able to tell how to extract the errors programmatically. Would you know? |
@adam-urbanczyk I found the messages can be extracted using import io
from OCP.Message import Message, Message_Gravity, Message_PrinterToReport
from OCP.STEPControl import STEPControl_Reader
msger = Message.DefaultMessenger_s()
newprinter = Message_PrinterToReport()
report = newprinter.Report()
msger.AddPrinter(newprinter)
reader = STEPControl_Reader()
reader.ReadFile("BROKEN_FILE.STEP")
f = io.BytesIO()
alerts = report.GetAlerts(Message_Gravity.Message_Info)
for alert in alerts:
alert.Attribute().DumpJson(f)
print(f.getvalue())
f.close() |
I get the same stacktrace in C++ and Draw with OSD::SetSignal(OSD_SignalMode_Unset, Standard_False); No crash with In Draw, default is set here: |
I opened an OCCT issue https://tracker.dev.opencascade.org/view.php?id=33603 @qbamca Can you also share the unmodified STEP file? Probably not useful but could see the diff. |
@lorenzncode what is the current conclusion regarding CQ? I.e. can we change some settings to mitigate the issue? |
@adam-urbanczyk Pending a fix in OCCT itself, yes it would be possible to mitigate the issue in CQ by conditionally aborting The simplest way might be to provide an option to abort on any alert (ignoring the contents of the messages). If we find it results in false positives then it might be required to check for specific messages. In C++ the issue can be mitigated with |
Thank you for the report. |
This kind of issue is not stable. The result is undefined if you will disable catching signals. |
@dpasukhi Thank you for your inputs! @adam-urbanczyk Since crashes are expected to be rare perhaps CQ can separate the |
I've added the original file in the repo. 3007091.STEP BTW, thank you all for looking into this. |
can you give me a short status report of this issue? |
Same here. Maybe take a look if #1525 helps you. It seems that there is no one liner that would solve this. You might need to handle such issues on your side using OCCT directly. |
The ticket is one of the first to fix. I wait for compleating another ticket for the developer. |
hi, it's been a while. |
From OCCT side the issue was resolved a long time ago. |
Probably when this lands in the OCCT release and when this release is wrapped and used in CQ. I assume 7.9, will take a while. |
Changes included into 7.8.1. |
Then stay tuned (#1589) |
7.7.2 -> 7.8.n is a little more complicated task. |
thank you guys! |
We run Flask app that converts step files to stl for further processing. When we were testing the app we noticed that when supplied with manually broken step file, the cadquery library crash gracefully our Flask app. No Error is raised. We tried catching SystemExit with no avail. The app just stops.
I've traced cadquery inner works up to this point:
at which the
reader.TransferRoot(i + 1)
closes our app.I don't know how to trace it further inside OCP, so I can't investigate further.
The problem is that, such files can close our service, we have no means to prevent it and results in service downtimes while it's being restarted.
We need to find a way to prevent it from closing the app.
To Reproduce
repro repo
It's a flask app. Run main.py and post file BROKE_FILE.STEP
Backtrace
Environment
OS:
Ubuntu 22.04.2 LTS
python 3.10.12
cadquery v2.3.1
cadquery is installed using pip.
Using: Python interpreter
The text was updated successfully, but these errors were encountered: