View · Search · Index
No registered users in community xowiki
in last 10 minutes

Re: [Xotcl] Segmentation fault

From: Kristoffer Lawson <setok_at_fishpool.com>
Date: Fri, 24 Sep 2004 16:32:42 +0300 (EEST)

On Fri, 24 Sep 2004, Kristoffer Lawson wrote:

> I'm getting a segmentation fault in relation to XOTcl. I believe the
> situation that causes it is as follows:
>
> * I have an object C which has a child M.
> * M has a fileevent callback.
> * On receiving complete message, M calls a method in C.
> * If that is an empty message, C destroys itself and closes the socket in the
> destructor (M is still in fileevent callback).

For what it's worth, here's some more information from the debug output:

Client connected.
  * init: MsgHandler init called
  * destroy: next
  * destroy: destroy MsgHandler
  * destroy: CmdHandler destroy
    * destroy: close socket
  * destroy: ClientConn destroy
  * destroy: destroy MsgHandler
  * destroy: destroy MsgHandler
  --var-- ::::readData: data: ,
  * MsgHandler readData: return
Segmentation fault

MsgHandler is the M object I was talking about, and is a child of
ClientConn and has a fileevent callback. The funny thing here is that
apparently the MsgHandler destructor gets called three times. Only one
MsgHandler object is created here (as can be seen: the init is only called
once). I guess this is something to do with the delayed destruction model,
or something?

The segmentation fault thus occurs after all the destructors have been
called and the event handler returns (the readData method of MsgHandler).

Hope this helps.

                               / http://www.fishpool.com/~setok/