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

Different exception behaviour between Debug and Release builds #454

Open
GVladislavG opened this issue Oct 11, 2023 · 7 comments
Open

Different exception behaviour between Debug and Release builds #454

GVladislavG opened this issue Oct 11, 2023 · 7 comments

Comments

@GVladislavG
Copy link

GVladislavG commented Oct 11, 2023

Hello, xBim team!

I've found very interesting moment.
I've changed Exceptions handling a little bit in XbimGeometryCreator.cpp. Strings 304-310.

catch (...)
{
	//throw gcnew Exception(String::Format("General Error Creating {0}, #{1}", geomRep->GetType()->Name, geomRep->EntityLabel));				
	
	LogError(logger, geomRep, "General Error Creating {0}, #{1}", geomRep->GetType()->Name, geomRep->EntityLabel);
	return XbimGeometryObjectSet::Empty;
} 

Then I built debug version of XBim.Geometry. All my problems with geometry creation have disappeared!))
But if I build release version of the same code, it doesn't work correctly.
Also if I move debug-dlls of xBim, that I've built on my computer, to other machine it doesn't work.
I use master-branch.
It would be greate to fix this problem!

Thanks!

@andyward andyward changed the title Problems in Xbim3DModelContext.CreateContext() Different exception behaviour between Debug and Release builds Oct 11, 2023
@GVladislavG
Copy link
Author

And there are also no Xbim.Geometry.Engine64.pdb and Xbim.Geometry.Engine32.pdb in release build configuration.
Release build throws exception in Xbim.Geometry.Engine64.dll while Xbim3DModelContext.CreateContext().
I tried to attach with debugger to learn deeper, but there is no symbol files in release.
Debug build doesn't throw any exception and works well.

@andyward
Copy link
Member

My C++ is rusty, but some thoughts:

In debug builds there are additional checks on things like stack & heap overruns - likely why it only fails in Release. (In debug I'd check for exceptions being raised and logged. Enable all C++ exceptions in the Exception Settings window).

Equally in Release config the debug symbols (PDBs) are not created - which is why you don't see the symbol files.

Things you can try:

  1. Enable / change Runtime Checks in Debug
image
  1. Change the Generate Debug Info setting in the Linker in Release
image

@GVladislavG
Copy link
Author

Is there any way to get the same behavior as debug build in release?
Skipping some exceptions and getting result geometry (maby with skiped elements) would be greate result for me now)

@andyward
Copy link
Member

Not really, short of using a debug (unoptimised) build. The /RTC (runtime checks) will only work in Debug/Un-optimised builds. https://learn.microsoft.com/en-us/cpp/build/reference/rtc-run-time-error-checks?view=msvc-170

What I'd hope the debug build willlet you do is identify the data / scenario that triggers the crash in Release. If you can track it down to a particular element others may be able to take a look.

@GVladislavG
Copy link
Author

So one more question.
Why debug-dlls don't work on other machine (without Visual Studio)?
Does it also means that I can't move them to other computer?

@andyward
Copy link
Member

I think it uses different C++ runtime/libs in DEBUG - and these won't be on machines without VS. Probably a good reason not to go down that route. Best approach is to get a fix for the actual problem - but will need your model (or a subset of it) to reproduce

@GVladislavG
Copy link
Author

GVladislavG commented Oct 13, 2023

Ok. There are three problem files in archive.
If I use XBim.Essentials ver 5.1.323 + XBim.Geometry ver 5.1.730-develop, it doesn't crash.
But result geometry in 3.ifc contains many incorrect results (screenshot below).
3Ifc
1.ifc and 2.ifc are OK.
If I use XBim.Essentials ver 6.0.427-develop + XBim.Geometry ver 5.1.730-develop, it crashes.

3.zip
ProblemIFCs.zip

This was referenced Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants