Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Segfault in Tk on Mac

19 views
Skip to first unread message

Kevin Walzer

unread,
Apr 23, 2012, 11:06:35 PM4/23/12
to
I'm trying to debug a segfault in Tk 8.5/Fossil on OS X Lion, and am
having difficulty.

After stepping through gdb, I trace the error to this backtrace:

0x0000000100176d5a in Tk_MacOSXSetupTkNotifier () at tkMacOSXNotify.c:167

After some logging of various commands, it appears that Wish is crashing
on this call, in tkMacOSXNotify.c:

TclMacOSXNotifierAddRunLoopMode(NSEventTrackingRunLoopMode);

Poking around further, I find this function defined in tclMacOSXNotify.c:

void
TclMacOSXNotifierAddRunLoopMode(
const void *runLoopMode)
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
CFStringRef mode = (CFStringRef) runLoopMode;

if (tsdPtr->runLoop) {
CFRunLoopAddSource(tsdPtr->runLoop, tsdPtr->runLoopSource, mode);
CFRunLoopAddObserver(tsdPtr->runLoop, tsdPtr->runLoopObserver, mode);
if (tsdPtr->runLoopTimer) {
CFRunLoopAddTimer(tsdPtr->runLoop, tsdPtr->runLoopTimer, mode);
}
}
}

It appears that the pointer address &dataKey is null, which causes the
crash. dataKey is defined at the beginning of the file, thus:

static Tcl_ThreadDataKey dataKey;

and is used throughout the tclMacOSXNotify.c file.

I can't figure out why the memory is being corrupted as this code has
worked fine, until very recently, and this particular file hasn't been
touched in a long time. Any suggestions as to what strategies I can
employ to investigate this further?

--Kevin




--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com

Kevin Walzer

unread,
Apr 23, 2012, 11:08:22 PM4/23/12
to
On 4/23/12 11:06 PM, Kevin Walzer wrote:
> I'm trying to debug a segfault in Tk 8.5/Fossil on OS X Lion, and am
> having difficulty.

Correction: tk 8.6/trunk from Fossil.

Christian Gollwitzer

unread,
Apr 24, 2012, 2:26:46 AM4/24/12
to
Am 24.04.12 05:06, schrieb Kevin Walzer:
Well, obviously you should try valgrind next, or some other memory
debugging library. Do you have a concise test script which crashes Tk? I
can try to run valgrind on my system if you provide it.

Christian

Donal K. Fellows

unread,
Apr 24, 2012, 4:23:44 AM4/24/12
to
On 24/04/2012 07:26, Christian Gollwitzer wrote:
> Well, obviously you should try valgrind next, or some other memory
> debugging library. Do you have a concise test script which crashes Tk? I
> can try to run valgrind on my system if you provide it.

If this is the problem I think it is, it also occurs with the backport
of the Cocoa layer to 8.5, it happens also with Leopard (can't test with
Snow Leopard, but if Leopard and Lion both have the problem, it's a fair
guess that the OS version isn't critical) and it happens _before_ any
scripts are run, during process startup. In other words, if you can run
wish and get a window showing, you've not duplicated the bug. :-)

Valgrinding it is a good idea. I've put a bug report in to track this
problem (http://sourceforge.net/support/tracker.php?aid=3520912) and
attached a valgrind trace to it. (It's against the 8.5 cocoa code,
because that's what I had the rest of my build env set up to work with
right now, but I think the problem is identical on 8.6.)

Donal.
0 new messages