Succesfull compile of OCC 6.2 on MacOS 10.4.9 but having problems running DRAWEXE

Hi List,

I've built, succesfully I think, OpenCASCADE on my Mac OS X 10.4.9 Dual Core Intel.
Having problems running the supplied demo application DRAWEXE.
It crashes with EXC_BAD_ACCESS
This demo application uses, I think, Tcl, Tk and X11.
I can run X11 applications, like InkScape, no problem.
I've been able to run it with the Xcode debugger (gdb) and single step to the offending statement.

The application starts and runs until 'XSynchronize' statement is reached (see code sample below).
If I comment that out the application runs untill it reaches 'XFlush' statement, see crash report below.

My presumption is that the application code is OK, after all it is part of a huge open source project OpenCASCADE
and I've not seen any reports on this sort of problem from people running it on Linuxes, Solaris or Windows.

So my thinking is that there is something wrong in my configuration or enviroment, or the way I link the Tcl,Tk&X11
libs to the application, or the way this code accesses them.

What I find strange is that the 'Draw_WindowDisplay' parameters that is passed to the crashing function 'XSyncronize'
has been returned from ' Tk_Display' a few line above, and looking with the debugger it looks like a bona fide address
AFAIU (0x2DA808). Moreover, the next function 'XSetInputFocus' seems to be totally happy with that pointer. If I
comment out the 'XSyncronize' the crash happens much later.

I'm lost here since my experience with X11 is limited, to say the least, though I've got some +25 years of C/C++/Java under my belt.

One hunch that I have is that somehow or other the code is using accessing wrong X11 libs from /usr/.... (there propably
are something there because I've used Fink to install some other packages) instead of the Apple Framework stuff.
Just a thought, don't realy understand how this is supposed to work.

The OpenCASCADE is a huge project (took 5 hours to compile on 2 GHZ dual core with 2 GB RAM) but amazingly
I had to do very minor adjustments to make it compile and link. Removed some malloc.h refs, fixed a wrong type
for 'pthread_t' and thats about it.

I also used the apple supplied glibtool and the linking and library building part all went smoothly.

So I expect I'm doing something right...;-)

Any ideas on what to check on my enviroment, installation, where to look for more information, how to debug, what to test?

br Kusti

// The configuration I used for building OpenCASCADE *********************************************

./configure CFLAGS="-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386" LDFLAGS="-arch i386" --with-gl-include=/Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/include --x-includes=/Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/include --x-libraries=/Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/lib --with-x --with-tcl=/System/Library/Frameworks/Tcl.framework --with-tk=/System/Library/Frameworks/Tk.framework

// CODE SAMPLE FOLLOWS *****************************************************

Standard_Boolean Init_Appli()
interp = theCommands.Interp();

Tcl_Init(interp) ;
try {
Tk_Init(interp) ;
} catch (Standard_Failure) {
cout }

Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL);

mainWindow =
Tk_MainWindow(interp) ;
if (mainWindow == NULL) {
fprintf(stderr, "%s\n", interp->result);
Tk_Name(mainWindow) =
"Draw")) ;

Tk_GeometryRequest(mainWindow, 200, 200);

if (Draw_WindowDisplay == NULL) {
Draw_WindowDisplay = Tk_Display(mainWindow) ;
if (Draw_WindowDisplay == NULL) {
cout cout return Standard_False;
// synchronize the display server : could be done within Tk_Init

********* EXECPTION HAPPENS ON THE NEXT LINE *************
XSynchronize(Draw_WindowDisplay, True);


Draw_WindowScreen = DefaultScreen(Draw_WindowDisplay);
Draw_WindowColorMap = DefaultColormap(Draw_WindowDisplay,
tty = isatty(0);

// CRASH REPORT FOLLOWS *****************************************************************************
Date/Time: 2007-03-26 10:15:46.957 +0300
OS Version: 10.4.9 (Build 8P2137)
Report Version: 4

Command: DRAWEXE
Path: /usr/local/bin/DRAWEXE
Parent: bash [16286]

Version: ??? (???)

PID: 16287
Thread: 0

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0x5c637273

Thread 0 Crashed:
0 libX11.6.dylib 0x9cdcfd04 XFlush + 23
1 libTKDraw.0.dylib 0x01040fde Draw_Window::Flush() + 28 (Draw_Window.cxx:593)
2 libTKDraw.0.dylib 0x0103b797 Draw_Viewer::Flush() + 31 (Draw_Viewer.cxx:1123)
3 libTKDraw.0.dylib 0x01020294 Draw_Interprete(char*) + 370 (Draw.cxx:360)
4 libTKDraw.0.dylib 0x010203ba ReadInitFile(char*) + 98 (Draw.cxx:113)
5 libTKDraw.0.dylib 0x0102071d Draw_Appli(int, char**, void (*)(Draw_Interpretor&)) + 843 (Draw.cxx:248)
6 libTKDraw.0.dylib 0x0102e93e main_(int, char**, void (*)(Draw_Interpretor&)) + 44 (Draw_Main.cxx:179)
7 DRAWEXE 0x00002dfa main + 40 (DRAWEXE.cxx:23)
8 DRAWEXE 0x00002736 _start + 216
9 DRAWEXE 0x0000265d start + 41

Thread 1:
0 libSystem.B.dylib 0x9001a0ec select + 12
1 libSystem.B.dylib 0x90024147 _pthread_body + 84

Thread 0 crashed with X86 Thread State (32-bit):
eax: 0x5c637273 ebx: 0x01040fce ecx: 0x0000001d edx: 0x010373e0
edi: 0x15e23e29 esi: 0x002cd808 ebp: 0xbffff978 esp: 0xbffff960
ss: 0x0000001f efl: 0x00010202 eip: 0x9cdcfd04 cs: 0x00000017
ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037

Binary Images Description:
0x1000 - 0x2fff DRAWEXE /usr/local/bin/DRAWEXE
0x1008000 - 0x1088fff libTKDraw.0.dylib /usr/local/lib/libTKDraw.0.dylib
0x1b1e000 - 0x1bc0fff libTKMesh.0.dylib /usr/local/lib/libTKMesh.0.dylib
0x274d000 - 0x2859fff libTKHLR.0.dylib /usr/local/lib/libTKHLR.0.dylib
0x41d5000 - 0x4704fff libTKGeomAlgo.0.dylib /usr/local/lib/libTKGeomAlgo.0.dylib
0x923d000 - 0x940efff libTKTopAlgo.0.dylib /usr/local/lib/libTKTopAlgo.0.dylib
0xb77b000 - 0xb819fff libTKBRep.0.dylib /usr/local/lib/libTKBRep.0.dylib
0xca1e000 - 0xce35fff libTKGeomBase.0.dylib /usr/local/lib/libTKGeomBase.0.dylib
0x105d6000 - 0x10640fff libTKG2d.0.dylib /usr/local/lib/libTKG2d.0.dylib
0x10f24000 - 0x11029fff libTKG3d.0.dylib /usr/local/lib/libTKG3d.0.dylib
0x121f5000 - 0x1236cfff libTKMath.0.dylib /usr/local/lib/libTKMath.0.dylib
0x1399a000 - 0x13b13fff libTKernel.0.dylib /usr/local/lib/libTKernel.0.dylib
0x8fe00000 - 0x8fe4afff dyld 46.12 /usr/lib/dyld
0x90000000 - 0x90172fff libSystem.B.dylib /usr/lib/libSystem.B.dylib

TRUNCATED BECAUSE OF mailing list limitations...