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

Failed to compile the code, cause SIGSTKSZ is now a run-time variable since glibc 2.34! #82

Open
laplacedoge opened this issue Mar 15, 2023 · 1 comment

Comments

@laplacedoge
Copy link

For my virtual machine, the clang++ version is "Ubuntu clang version 14.0.0-1ubuntu1", and the g++ version is "gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)".

I tried both of them, but still got failed to compile it, here is the terminal output when using clang++:

clang++ -Ilib -Icommon -Iexternals/tinyxml   -std=c++0x -O2 -include lib/cxx11emu.h -DNDEBUG -Wall -Wno-sign-compare -Wno-unknown-pragmas -Wno-reorder  -c -o cli/tscexecutor.o cli/tscexecutor.cpp
cli/tscexecutor.cpp:322:13: error: variable length array declaration not allowed at file scope
static char mytstack[MYSTACKSIZE]; // alternative stack for signal handler
            ^        ~~~~~~~~~~~
1 error generated.
make: *** [Makefile:284: cli/tscexecutor.o] Error 1

Obviously, the option "-std=c++0x" is already specified in the compile command, but the compiler still said the length of the array "mytstack" is not constant, so I checked the code at cli/tscexecutor.cpp:322:13:

static const size_t MYSTACKSIZE = 16 * 1024 + SIGSTKSZ; // wild guess about a reasonable buffer
static char mytstack[MYSTACKSIZE]; // alternative stack for signal handler
static bool bStackBelowHeap = false; // lame attempt to locate heap vs. stack address space

SIGTKSZ is now not a macro anymore, here is the news.

Maybe it's a better choice to allocate this array dynamically now.

@ayoubelmhamdi
Copy link

i don't know how is the SIGSTKSZ calculated, but i use one random from GitHub search,
but, it's look work for me:

diff --git a/trunk/cli/tscexecutor.cpp b/trunk/cli/tscexecutor.cpp
index e384c09..3205cc3 100644
--- a/trunk/cli/tscexecutor.cpp
+++ b/trunk/cli/tscexecutor.cpp
@@ -318,7 +318,8 @@ static void print_stacktrace(FILE* f, bool demangling, int maxdepth)
 #endif
 }
 
-static const size_t MYSTACKSIZE = 16 * 1024 + SIGSTKSZ; // wild guess about a reasonable buffer
+
+static const size_t MYSTACKSIZE = 16 * 1024 + (int)250L; // wild guess about a reasonable buffer
 static char mytstack[MYSTACKSIZE]; // alternative stack for signal handler
 static bool bStackBelowHeap = false; // lame attempt to locate heap vs. stack address space
 
diff --git a/trunk/cli/tscthreadexecutor.cpp b/trunk/cli/tscthreadexecutor.cpp
index 551a88d..5a4e7ca 100644
--- a/trunk/cli/tscthreadexecutor.cpp
+++ b/trunk/cli/tscthreadexecutor.cpp
@@ -1,4 +1,4 @@
-
+#include <cstdint>
 
 #include "tscthreadexecutor.h"
 #include "tscancode.h"

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