PtTextModifyText segfaults in detached thread

Hello… Today i was bitten by a peculier problem… I made an app in PhAB
with tabs and a Log message window (PtMultiText) (on one tab)… I needed
some initialization to be performed when the app starts so i attached a
Pt_CB_REALIZED Callback to the main window. In that callback I logged many
messages to the Message using PtTextModifyText(), this was fine until i
created a thread from within the callback and wanted to log some information
to the message window using the same call

PtTextModifyText(ABW_PtMultiText_MSG, NULL, NULL, -1, str, strlen(str));
//str is different and defined in both contexts…

The problem is that I cannot log messages from the spawned thread. whenever I
want to it seg faults… (there are no race conditions… i used mutexes as
precaution and even introduced a 2s delay… my printfs tell me the parent
function exits before the thread calls PtTextModifyText()… also a
printf(str) just before the PtTextModifyText() works smoothly… so no NULL
pointers etc…)

Please enlighten me where I have gone wrong… is accessing widgets from
inside a spawned thread a taboo or some special setup is reqiored for it!!

Keep Smiling

Mechanically Yours

  • Mritunjai

A ship ought not to be held by one anchor, nor life by a single hope.

Sophomore Undergraduate
Mechanical Engg.
Indian Institute of Technology Bombay

Sent via