Re: $w->cb(undef) causes segfaults. (+patch)

[email protected] (Damien Neil)
Newsgroups perl.loop
Message-ID <[email protected]>
On Thu, May 31, 2001 at 12:06:15PM -0400, Uri Guttman wrote:
>   DN>            Watchers are stopped implicitly if their new
>   DN>            configuration deprives them of the ability to generate
>   DN>            events.
> 
> events are not callbacks. theoretically you could have an event with an
> implied action and no callback. the bug is as i said, it should not call
> the null callback. cancelling the watcher because of no callback makes
> no sense. you just cancel the watcher.

I have a watcher with a callback of [ $obj, "method" ].  $obj contains
a reference to the watcher, creating a circular reference chain.  I
want $obj to be GCd, so I need to either remove the watcher's reference
to $obj, or vice-versa.

Destroying the watcher is insufficient, as this does not free the
contents of its cb attribute.  I need to explicitly undefine the
callback.

The above quote from the manpage indicates, by my reading, that
removing the callback implicitly stops the watcher.  To support this
reading, I quote from elsewhere in the manpage:

       $watcher->start
           Activate the watcher.  Watchers refuse to start()
           without sufficient configuration information to
           generate events.  Constructors always invoke start()
           unless the parked=1> option is requested.  You will
           need to set the parked option if you preallocate
           unconfigured watchers.

If I create a watcher with no cb attribute and without the parked
option, I receive an exception: "Event: can't start '?? boom:11'
without callback".  I interpret this as occurring because the watcher
does not have sufficient configuration information to generate
events: events must have an associated callback.

The alternative is to say that it is acceptable for an io watcher
to spin, generating a continuous series of callbackless events,
if it is configured without a callback.


> and it is not a perl bug in any case. it is trivial to get perl to core
> dump from an XS module.

I did not say that it is a bug in perl.

I am currently feeling quite frustrated.  I spent some time tracking
down the bug (not a perl bug; a bug in Event) which was causing my
program to core dump.  I found it, and submitted a description and
patch to the appropriate people.  In return, I am being told that
I am the one at fault.

                    - Damien
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.