-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
GLM_FORCE_CTOR_INIT needed for preprocessor macros #6530
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
Comments
hmm. Is meant to set a and b to 0,0,0. can you cout a and b and share? I am assuming you have the glm libs updated from apothecary or from the latest release? |
So, I ran into this problem and it took me several days to figure it out. I found that it happened in my addons where I was including glm headers without including Anyway, it was a huge headache and I'd strongly advocate that we not define This is all very odd because I usually include |
Initially I thought we shouldn't include GLM_FORCE_CTOR_INIT. But in the OF core it took forever to track down and fix bugs related to quats and vecs not being set. I think it could bring a bunch of misery to people's projects and break addons ( which are 0.11.0 compatible but aren't being updated regularly ) to not have that include. At the same time I understand that you'll end up with two types of glm code - some which assumes auto initialization and some which doesn't. I am not sure if there is a graceful way to transition from it ( like deprecation )? Maybe there is? The code @neilmendoza posted above wouldn't be valid without it:
|
It also took me all day to track down this bug. That code actually has a and b initialized in the project I'm working on that I copied it from. I don't care about the values of a, b and c being garbage though, that's just the minimal code I could give as an example that is causing memory corruptions elsewhere (in the tinynurbs library in this case) when GLM_FORCE_CTOR_INIT is defined. Makes sense that is might be due to different defines for glm in different files based on includes. Will have a look later. |
Yeah, I understand it's a tough call. I think you probably made the right
one for the sake of addons. We should probably document it more clearly
somewhere in a document of "known issues" or something.
…On Tue, Jan 28, 2020, 6:41 PM Neil Mendoza ***@***.***> wrote:
It also took me all day to track down this bug. That code actually has *a*
and *b* initialized in the project I'm working on that I copied it from.
I don't care about the values of *a*, *b* and *c* being garbage though,
that's just the minimal code I could give as an example that is causing
memory corruptions elsewhere (in the tinylib library in this case) when
GLM_FORCE_CTOR_INIT is defined. Makes sense that is might be due to
different defines for glm in different files based on includes. Will have a
look later.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6530?email_source=notifications&email_token=AACJLRDKHMEI6CVBKUYJ62LRADGFLA5CNFSM4KM3F3D2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKFRRYQ#issuecomment-579541218>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACJLREFHMJOCPJG2J7HR3TRADGFLANCNFSM4KM3F3DQ>
.
|
Yeah, agree it's a tough choice. Seems like this opens the door to some pretty gnarly bugs if you can't use anything that depends on glm without including the OF headers in the correct place. Would be nicer if GLM_FORCE_CTOR_INIT could be defined in the project rather than an include file. |
Adding this to projects seems the best solution, |
This bit ofxLua for a while. I didn't know what was going on until someone pointed out the glm define. The main thing it seemed to effect was causing a runtime crash only in Debug builds: danomatika/ofxLua#58 |
I just came across this memory corruption issue again and wasted another few hours. It would really be much better to get the project generator to include this as a preprocessor macro. If not, you end up with memory corruptions every time you include a glm header directly without ofConstants.h first. Seems like the people on this thread that tracked down why their code is misbehaving are all pretty experienced OF users. I'm guessing there are a lot of other people that never manage to figure out why their code randomly does unexpected things. |
Nice @neilmendoza I think it is a good idea. what do you think @ofTheo? |
Yeah, totally agree.
Honestly feel it shouldn't almost be a patch to GLM or part of apothecary but I'd be down to adding it to pre processor macros for all platforms.
|
Working on adding this to preprocessor definitions. I noticed that
|
Yes I think so! |
What I did in my fork was totally remove GLM_FORCE_CTOR_INIT by initializing all mat4 by { 1.0f } It is a way of avoid GLM including files it won't use or doing unnecessary operations. |
@dimitre we need Too many addons will break and the ways that they are break are really subtle and hard to track down. The small benefit is not worth the collective time that will be wasted across projects. |
@ofTheo ok ![]() |
Thanks @dimitre Also, after 0.12.1 we can do a good check of the OF core and make sure all glm variable inside OF are initialized and just have We'll over engineer it for now with Nick's PR and then do a more thorough cleanup post 0.12.1 |
Closed by #8352 |
I just updated to the latest version of OF and commit a9e962c is giving me some strange issues. In the example for ofxTinynurbs, if I add...
...at the start of ofApp::setup(), the data in ofxTinynurbs gets corrupted with OF commit a9e962c or later (where GLM_FORCE_CTOR_INIT is added).
The text was updated successfully, but these errors were encountered: