-
Notifications
You must be signed in to change notification settings - Fork 511
stack overflow when compiling win32 - solved #92
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
Yes, this has been a problem with debug builds in the past with other functions... interestingly, VS2013 doesn't have that. Ideally this should be fixed by redoing the way the text window works. |
@jmkinzer, thank you, I have the same issue but not actually try to understand why it happens. |
Got the same issue. |
This allowed me to compile in VS2017-- will this be added to master? |
Fixed in master. |
@whitequark
The lines in question are these: So the analyser thinks that this constructor:
somehow temporarily puts a copy of both |
I know that this is/was the case, no need to confirm anything. Fixing this properly requires rewriting the text window completely to use a less primitive rendering approach. This is complicated: it really ought to use Freetype and sprite atlases to handle CJK with good resolution as well as to allow changing text window size. So this isn't done yet. I'm not really interested in replacing the current (poor) solution that commits 26 MB of stack with another hack. |
See: solvespace#92 (comment) The problem was first introduced here: solvespace@dabd578 and later "fixed" here: solvespace@f324477 by setting the stack size to /STACK:33554432 Solvespace now starts up even with /STACK:554432 The only question now is whether omitting the {} in TextWindow and System constructor calls in the initializer list of the SolveSpaceUI constructor has any adverse effect.
Hmmm... I think the problem is that Solvespace runs. The only remaining question is whether omitting the
But it is not "pretty" from "architecture" point of view. |
There is nothing "not pretty" about (If you're observant, you might have noticed that |
Thanks for making me think harder (I'm a So omitting the In this case what is the proper way to initialize these two instances without using |
Here are the exact rules 1 2 3 for our case. They cause no shortage of bugs, and are a good example of why C++ should not be used for new projects. In practice, the worst issues result from the fact that once you add a base class, in C++11, doing In practice adding default member initializers ( |
Thanks! I read them all, plus these: |
Why? I don't see what guarantees that System is initialized at all. |
From 1: "2) if T is a class type with a default constructor that is neither user-provided nor deleted (that is, it may be a class with an implicitly-defined or defaulted default constructor), the object is zero-initialized and then it is default-initialized if it has a non-trivial default constructor; " But all 5 links we discussed make it hard to be sure - that is why I debugged it, and at least VS2019 does call memset on it (as seen in the video), which is no proof, just another data poit :-) |
@ruevs Hm, OK. Then you also should take out the |
See: solvespace#92 (comment) The problem was first introduced here: solvespace@dabd578 and later "fixed" here: solvespace@f324477 by setting the stack size to /STACK:33554432 Solvespace now starts up even with /STACK:554432 The only question now is whether omitting the {} in TextWindow and System constructor calls in the initializer list of the SolveSpaceUI constructor has any adverse effect.
See: solvespace#92 (comment) The problem was first introduced here: solvespace@dabd578 and later "fixed" here: solvespace@f324477 by setting the stack size to /STACK:33554432 Solvespace now starts up even with /STACK:554432 According to this: https://en.cppreference.com/w/cpp/language/value_initialization ``` "2) if T is a class type with a default constructor that is neither user-provided nor deleted (that is, it may be a class with an implicitly-defined or defaulted default constructor), the object is zero-initialized and then it is default-initialized if it has a non-trivial default constructor; " ``` So removing the `{}` should leave both the `System` and `TextWindow` class instances properly initialized.
Done. Found it only here: |
@whitequark are you waiting for something else from me? |
@ruevs Sorry, I missed this comment somehow. Which PR should I merge? |
This one: |
See: #92 (comment) The problem was first introduced here: dabd578 and later "fixed" here: f324477 by setting the stack size to /STACK:33554432 Solvespace now starts up even with /STACK:554432 According to this: https://en.cppreference.com/w/cpp/language/value_initialization ``` "2) if T is a class type with a default constructor that is neither user-provided nor deleted (that is, it may be a class with an implicitly-defined or defaulted default constructor), the object is zero-initialized and then it is default-initialized if it has a non-trivial default constructor; " ``` So removing the `{}` should leave both the `System` and `TextWindow` class instances properly initialized.
See: solvespace#92 (comment) The problem was first introduced here: solvespace@dabd578 and later "fixed" here: solvespace@f324477 by setting the stack size to /STACK:33554432 Solvespace now starts up even with /STACK:554432 According to this: https://en.cppreference.com/w/cpp/language/value_initialization ``` "2) if T is a class type with a default constructor that is neither user-provided nor deleted (that is, it may be a class with an implicitly-defined or defaulted default constructor), the object is zero-initialized and then it is default-initialized if it has a non-trivial default constructor; " ``` So removing the `{}` should leave both the `System` and `TextWindow` class instances properly initialized.
Compiling under VS2015 I received an immediate crash due to stack overflow initializing SolveSpace::SS (at least under the debug build). I found it necessary to bump the stack to around 32MB to resolve this, i.e.:
/STACK:33554432
Would recommend adding something like this to CMakeLists.txt (untested):
if(MSVC) set(CMAKE_EXE_LINKER_FLAGS "/STACK:33554432 ${CMAKE_EXE_LINKER_FLAGS}") endif()
The text was updated successfully, but these errors were encountered: