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

Mac Lion SFML 1.6 Crash #46

Closed
Omegaice opened this issue Oct 19, 2011 · 3 comments
Closed

Mac Lion SFML 1.6 Crash #46

Omegaice opened this issue Oct 19, 2011 · 3 comments
Assignees
Labels

Comments

@Omegaice
Copy link

[omegaice@MacPheonix:~/Documents/Code/visarray/viewer/molecular/build/Debug]% DYLD_LIBRARY_PATH=/usr/local/Cellar/apitrace/HEAD/wrappers/ gdb Molecular
GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 8 20:32:45 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...
warning: Unable to read symbols for @executable_path/../Frameworks/sfml-system.framework/Versions/A/sfml-system (file not found).

warning: Unable to read symbols from "sfml-system" (not yet mapped into memory).

warning: Unable to read symbols for @executable_path/../Frameworks/sfml-window.framework/Versions/A/sfml-window (file not found).

warning: Unable to read symbols from "sfml-window" (not yet mapped into memory).

warning: Unable to read symbols for @executable_path/../Frameworks/sfml-graphics.framework/Versions/A/sfml-graphics (file not found).

warning: Unable to read symbols from "sfml-graphics" (not yet mapped into memory).
Reading symbols for shared libraries ..... done

(gdb) r
Starting program: /Users/omegaice/Documents/Code/visarray/viewer/molecular/build/Debug/Molecular
Reading symbols for shared libraries ...++++......................................................................................................................................... done
Reading symbols for shared libraries . done

Program received signal SIGABRT, Aborted.
0x00007fff8bbc9ce2 in __pthread_kill ()
(gdb) backtrace
#0 0x00007fff8bbc9ce2 in __pthread_kill ()
#1 0x00007fff8c17b7d2 in pthread_kill ()
#2 0x00007fff8c16cb4a in __abort ()
#3 0x00007fff8c169070 in __stack_chk_fail ()
#4 0x0000000100551a6b in OS::GetProcessName ()
#5 0x00000001005513a5 in Trace::LocalWriter::open ()
#6 0x000000010055147e in Trace::LocalWriter::beginEnter ()
#7 0x00000001004a97a6 in CGLSetOption ()
#8 0x00007fff91750115 in createPixelFormat ()
#9 0x00007fff917500be in -NSOpenGLPixelFormat initWithAttributes:
#10 0x00000001001d3f86 in -sfPrivGLContext initWithAttributes:mode:sharedContext:
#11 0x00000001001d3dde in +sfPrivGLContext sharedContext
#12 0x00000001001c813c in sf::priv::WindowImplCocoa::WindowImplCocoa ()
#13 0x00000001001c7e15 in sf::priv::WindowImpl::New ()
#14 0x00000001001c7bf1 in sf::Context::Context ()
#15 0x00000001001c7c65 in sf::Context::GetGlobal ()
#16 0x00000001001c7cd5 in __static_initialization_and_destruction_0 ()
#17 0x00007fff5fc0fd1a in __dyld__ZN16ImageLoaderMachO18doModInitFunctionsERKN11ImageLoader11LinkContextE ()
#18 0x00007fff5fc0fa66 in __dyld__ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE ()
#19 0x00007fff5fc0d258 in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListE ()
#20 0x00007fff5fc0d1f1 in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListE ()
#21 0x00007fff5fc0e02b in __dyld__ZN11ImageLoader15runInitializersERKNS_11LinkContextERNS_21InitializerTimingListE ()
#22 0x00007fff5fc034ad in __dyld__ZN4dyld24initializeMainExecutableEv ()
#23 0x00007fff5fc07580 in _dyld__ZN4dyld5_mainEPK12macho_headermiPPKcS5_S5 ()
#24 0x00007fff5fc01059 in __dyld__dyld_start ()

@jrfonseca
Copy link
Member

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);

@jrfonseca
Copy link
Member

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.

@ghost ghost assigned jrfonseca Oct 20, 2011
@jrfonseca
Copy link
Member

This should be now fixed with commit 0a41c9b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants