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

segfault at Tcl_CreateEventSource

16 views
Skip to first unread message

tcli...@gmail.com

unread,
Nov 21, 2017, 1:45:51 AM11/21/17
to
Hi:
I have a program which works fine in Fedora 14 but segfault at Tcl_CreateEventSource() in Ubuntu 16.04.
The program uses Tcl8.5 in both environments.

The following are source code and stack trace.

Any suggestion or comment are welcomed.

Thanks

-Todd

// ---- BEGIN

#include "libguMain.h"
2 #include "libguMainWindow.h"
3 #include "libioReport.h"
4 #include "libioFilePtrManager.h"
5 //
6 // Global variable : ppMainWindow
7 guMainWindow *ppMainWindow; //
8 //---------------------------------------------------------------
9 static int handleEvent(Tcl_Event * pEvent,
10 int flags
11 )
12 {
13
14 if ((flags & TCL_IDLE_EVENTS) == 0) {
15 return 0;
16 }
17 return 1;
18
19 }
20
21 //---------------------------------------------------------------
22 static void eventSetupProc(ClientData clientData,
23 int flags
24 )
25 {
26
27 Tcl_Time maxBlockTime;
28
29 if ((flags & TCL_IDLE_EVENTS) == 0) {
30 return;
31 }
32 maxBlockTime.sec = 0;
33 maxBlockTime.usec = 50000;
34 Tcl_SetMaxBlockTime(&maxBlockTime);
35
36 }
37
38 //-----------------------------------------------------------------------------
39 static void eventCheckProc(ClientData clientData,
40 int flags
41 )
42 {
43
44 Tcl_Event * pEvent;
45
46 if ((flags & TCL_IDLE_EVENTS) == 0) {
47 return;
48 }
49 pEvent = (Tcl_Event *)Tcl_Alloc(sizeof (Tcl_Event));
50 pEvent->proc = handleEvent;
51 Tcl_QueueEvent(pEvent, TCL_QUEUE_TAIL);
52
53 }
54
55
56 //------------------------------------------------------------------------------
57 static void qtloop(void)
58 {
59
60 while (true) {
61 if( qApp->hasPendingEvents()) {
62 qApp->processEvents();
63 }
64 Tcl_DoOneEvent(0);
65 }
66
67 }
68
69
70 //-------------------------------------------------------------------------------
71 static void exitProc(ClientData clientData)
72 {
73
74 char cmdBuff[1024];
75 sprintf(cmdBuff, "# exit" );
76 ioReport::fprintfI(ioReport::getLogFp(), "%s\n", cmdBuff);
77 fflush(ioReport::getLogFp());
78
79
80 // close mainWindow
81 if (ppMainWindow) {
82 ppMainWindow->close();
83 delete ppMainWindow;
84 }
85
86 // close design
87 if (dbManager::getOAdesign()) {
88 dbManager::closeOAdesign();
89 }
90
91 // exit Qt
92 QApplication::exit(0); // exit Qt
93
94
95 // close file manager
96 ioFilePtrManager *fpm = ioFilePtrManager::getIOfilePtrManager();
97 delete fpm;
98
99 // close log file
100 ioReport *log = ioReport::getIOreport(); // Singleton
101 ioReport::printf("\n\t\t~~~ END ~~~\n");
102 fflush(ioReport::getLogFp());
103 delete log;
104
105 }
106

//--------------------------------------------------------------------------------
108 int
109 guMain::run()
110 {
111
112 QApplication a(_argc, _argv);
113 ppMainWindow = guMainWindow::getGuMainWindow();
114
115 Tcl_CreateEventSource(eventSetupProc, eventCheckProc, NULL);
116
117 Tcl_SetMainLoop(qtloop);
118 Tcl_CreateExitHandler(exitProc, NULL);
119
120 Tcl_Main(_argc, _argv, Tcl_AppInit); // enter the loop
121
122 return 1; // never got here
123
124 //a.setMainWidget(w);
125 // w->show();
126 // return a.exec();
127

--- END

Thread 1 "pp" received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) where
#0 0x0000000000000000 in ?? ()
#1 0x00007ffff7b784a6 in ?? () from /usr/lib/x86_64-linux-gnu/libtcl8.5.so
#2 0x00007ffff7b785c1 in ?? () from /usr/lib/x86_64-linux-gnu/libtcl8.5.so
#3 0x00007ffff7b7737f in Tcl_GetThreadData () from /usr/lib/x86_64-linux-gnu/libtcl8.5.so
#4 0x00007ffff7b59c84 in Tcl_CreateEventSource () from /usr/lib/x86_64-linux-gnu/libtcl8.5.so
#5 0x00000000005d40ae in guMain::run (this=0x7fffffffdfa0) at guMain.cpp:115
#6 0x000000000057b056 in main (argc=1, argv=0x7fffffffe0a8) at ./src/main.cpp:74
0 new messages