Giter Site home page Giter Site logo

Mac Lion SFML 1.6 Crash about apitrace HOT 3 CLOSED

apitrace avatar apitrace commented on May 15, 2024
Mac Lion SFML 1.6 Crash

from apitrace.

Comments (3)

jrfonseca avatar jrfonseca commented on May 15, 2024

It looks like we're overflowing the stack on MacOSX due to all foo[PATH_MAX] arrays allocated out of the stack.

This should fix it:

diff --git a/common/os_posix.cpp b/common/os_posix.cpp
index 98a790b..15999a9 100644
--- a/common/os_posix.cpp
+++ b/common/os_posix.cpp
@@ -67,7 +67,7 @@ ReleaseMutex(void)
bool
GetProcessName(char *str, size_t size)
{
- char szProcessPath[PATH_MAX + 1];
+ static char szProcessPath[PATH_MAX + 1];
char *lpProcessName;

     // http://stackoverflow.com/questions/1023306/finding-current-executables-path-without-proc-self-exe
diff --git a/common/trace_local_writer.cpp b/common/trace_local_writer.cpp
index e560e49..299878a 100644
--- a/common/trace_local_writer.cpp
+++ b/common/trace_local_writer.cpp
@@ -77,7 +77,7 @@ LocalWriter::open(void) {
     static unsigned dwCounter = 0;

     const char *szExtension = "trace";
-    char szFileName[PATH_MAX];
+    static char szFileName[PATH_MAX];
     const char *lpFileName;

     lpFileName = getenv("TRACE_FILE");
@@ -85,8 +85,8 @@ LocalWriter::open(void) {
         strncpy(szFileName, lpFileName, PATH_MAX);
     }
     else {
-        char szProcessName[PATH_MAX];
-        char szCurrentDir[PATH_MAX];
+        static char szProcessName[PATH_MAX];
+        static char szCurrentDir[PATH_MAX];
         OS::GetProcessName(szProcessName, PATH_MAX);
         OS::GetCurrentDir(szCurrentDir, PATH_MAX);

from apitrace.

jrfonseca avatar jrfonseca commented on May 15, 2024

Formatting got broken. I'll try paste once again:

diff --git a/common/os_posix.cpp b/common/os_posix.cpp
index 98a790b..15999a9 100644
--- a/common/os_posix.cpp
+++ b/common/os_posix.cpp
@@ -67,7 +67,7 @@ ReleaseMutex(void)
 bool
 GetProcessName(char *str, size_t size)
 {
-    char szProcessPath[PATH_MAX + 1];
+    static char szProcessPath[PATH_MAX + 1];
     char *lpProcessName;

     // http://stackoverflow.com/questions/1023306/finding-current-executables-path-without-proc-self-exe
diff --git a/common/trace_local_writer.cpp b/common/trace_local_writer.cpp
index e560e49..299878a 100644
--- a/common/trace_local_writer.cpp
+++ b/common/trace_local_writer.cpp
@@ -77,7 +77,7 @@ LocalWriter::open(void) {
     static unsigned dwCounter = 0;

     const char *szExtension = "trace";
-    char szFileName[PATH_MAX];
+    static char szFileName[PATH_MAX];
     const char *lpFileName;

     lpFileName = getenv("TRACE_FILE");
@@ -85,8 +85,8 @@ LocalWriter::open(void) {
         strncpy(szFileName, lpFileName, PATH_MAX);
     }
     else {
-        char szProcessName[PATH_MAX];
-        char szCurrentDir[PATH_MAX];
+        static char szProcessName[PATH_MAX];
+        static char szCurrentDir[PATH_MAX];
         OS::GetProcessName(szProcessName, PATH_MAX);
         OS::GetCurrentDir(szCurrentDir, PATH_MAX);

I won't commit this immediately because static arrays are a bit unclean (subject to race conditions), but I don't want to use malloc here neither... I'll just have to think a bit more about this.

from apitrace.

jrfonseca avatar jrfonseca commented on May 15, 2024

This should be now fixed with commit 0a41c9b

from apitrace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.