unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29450: 26.0.90; No check for nil in some filenotify functions
@ 2017-11-26  6:18 John Wiegley
  2017-11-26 15:39 ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: John Wiegley @ 2017-11-26  6:18 UTC (permalink / raw)
  To: 29450

The documentation for find-file-name-handler says:

    find-file-name-handler is a built-in function in ‘C source code’.
    
    (find-file-name-handler FILENAME OPERATION)
    
    Return FILENAME’s handler function for OPERATION, if it has one.
    Otherwise, return nil.

However, several of the functions in filenotify use the return value of this
function without checking if it's nil or not:

    (defun file-notify-rm-watch (descriptor)
      "Remove an existing watch specified by its DESCRIPTOR.
    DESCRIPTOR should be an object returned by `file-notify-add-watch'."
      (when-let* ((watch (gethash descriptor file-notify-descriptors)))
        (let ((handler (find-file-name-handler
                        (file-notify--watch-directory watch)
                        'file-notify-rm-watch)))
          (condition-case nil
              (if handler
                  ;; A file name handler could exist even if there is no
                  ;; local file notification support.
                  (funcall handler 'file-notify-rm-watch descriptor)

I've been getting several errors with a backtrace like nil(48). This is likely
because some package has done something wrong, but even still, filenotify
should be more defensive.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#29450: 26.0.90; No check for nil in some filenotify functions
  2017-11-26  6:18 bug#29450: 26.0.90; No check for nil in some filenotify functions John Wiegley
@ 2017-11-26 15:39 ` Eli Zaretskii
  2018-01-10  0:28   ` Glenn Morris
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2017-11-26 15:39 UTC (permalink / raw)
  To: John Wiegley; +Cc: 29450

> From: "John Wiegley" <johnw@gnu.org>
> Date: Sat, 25 Nov 2017 22:18:07 -0800
> 
> The documentation for find-file-name-handler says:
> 
>     find-file-name-handler is a built-in function in ‘C source code’.
>     
>     (find-file-name-handler FILENAME OPERATION)
>     
>     Return FILENAME’s handler function for OPERATION, if it has one.
>     Otherwise, return nil.
> 
> However, several of the functions in filenotify use the return value of this
> function without checking if it's nil or not:

Maybe I'm blind, but I cannot find any place in filenotify where the
handler is used without checking, including in the case you show:

>     (defun file-notify-rm-watch (descriptor)
>       "Remove an existing watch specified by its DESCRIPTOR.
>     DESCRIPTOR should be an object returned by `file-notify-add-watch'."
>       (when-let* ((watch (gethash descriptor file-notify-descriptors)))
>         (let ((handler (find-file-name-handler
>                         (file-notify--watch-directory watch)
>                         'file-notify-rm-watch)))
>           (condition-case nil
>               (if handler <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>                   ;; A file name handler could exist even if there is no
>                   ;; local file notification support.
>                   (funcall handler 'file-notify-rm-watch descriptor)

What am I missing?

> I've been getting several errors with a backtrace like nil(48). This is likely
> because some package has done something wrong, but even still, filenotify
> should be more defensive.

Can you show a full backtrace like that?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#29450: 26.0.90; No check for nil in some filenotify functions
  2017-11-26 15:39 ` Eli Zaretskii
@ 2018-01-10  0:28   ` Glenn Morris
  2018-01-10 23:56     ` John Wiegley
  0 siblings, 1 reply; 7+ messages in thread
From: Glenn Morris @ 2018-01-10  0:28 UTC (permalink / raw)
  To: John Wiegley, 29450

Eli Zaretskii wrote:

>> From: "John Wiegley" <johnw@gnu.org>
>> Date: Sat, 25 Nov 2017 22:18:07 -0800
>> 
>> The documentation for find-file-name-handler says:
>> 
>>     find-file-name-handler is a built-in function in ‘C source code’.
>>     
>>     (find-file-name-handler FILENAME OPERATION)
>>     
>>     Return FILENAME’s handler function for OPERATION, if it has one.
>>     Otherwise, return nil.
>> 
>> However, several of the functions in filenotify use the return value of this
>> function without checking if it's nil or not:
>
> Maybe I'm blind, but I cannot find any place in filenotify where the
> handler is used without checking, including in the case you show:
>
>>     (defun file-notify-rm-watch (descriptor)
>>       "Remove an existing watch specified by its DESCRIPTOR.
>>     DESCRIPTOR should be an object returned by `file-notify-add-watch'."
>>       (when-let* ((watch (gethash descriptor file-notify-descriptors)))
>>         (let ((handler (find-file-name-handler
>>                         (file-notify--watch-directory watch)
>>                         'file-notify-rm-watch)))
>>           (condition-case nil
>>               (if handler <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>>                   ;; A file name handler could exist even if there is no
>>                   ;; local file notification support.
>>                   (funcall handler 'file-notify-rm-watch descriptor)
>
> What am I missing?
>
>> I've been getting several errors with a backtrace like nil(48). This is likely
>> because some package has done something wrong, but even still, filenotify
>> should be more defensive.
>
> Can you show a full backtrace like that?


Any update?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#29450: 26.0.90; No check for nil in some filenotify functions
  2018-01-10  0:28   ` Glenn Morris
@ 2018-01-10 23:56     ` John Wiegley
  2018-01-11  9:13       ` Michael Albinus
  0 siblings, 1 reply; 7+ messages in thread
From: John Wiegley @ 2018-01-10 23:56 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 29450

>>>>> "GM" == Glenn Morris <rgm@gnu.org> writes:

>>> I've been getting several errors with a backtrace like nil(48). This is
>>> likely because some package has done something wrong, but even still,
>>> filenotify should be more defensive.
>> 
>> Can you show a full backtrace like that?

GM> Any update?

I worked around this with (setq auto-revert-use-notify nil). If it doesn't
happen for anyone else, you can close it. I'll look into it again if I ever
decide to re-enable this.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#29450: 26.0.90; No check for nil in some filenotify functions
  2018-01-10 23:56     ` John Wiegley
@ 2018-01-11  9:13       ` Michael Albinus
  2018-02-05  6:48         ` John Wiegley
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Albinus @ 2018-01-11  9:13 UTC (permalink / raw)
  To: John Wiegley; +Cc: 29450

John Wiegley <johnw@gnu.org> writes:

Hi,

Sorry to jump in such late; I've overlooked this thread before.

>>>> I've been getting several errors with a backtrace like nil(48). This is
>>>> likely because some package has done something wrong, but even still,
>>>> filenotify should be more defensive.
>>> 
>>> Can you show a full backtrace like that?
>
> I worked around this with (setq auto-revert-use-notify nil). If it doesn't
> happen for anyone else, you can close it. I'll look into it again if I ever
> decide to re-enable this.

I still would like to see a full backtrace. You have quoted

--8<---------------cut here---------------start------------->8---
      (when-let* ((watch (gethash descriptor file-notify-descriptors)))
        (let ((handler (find-file-name-handler
                        (file-notify--watch-directory watch)
                        'file-notify-rm-watch)))
 --8<---------------cut here---------------end--------------->8---

I have the feeling that it isn't the return value of
`find-file-name-handler' being nil, but rather the
`file-notify--watch-directory' call.

Best regards, Michael.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#29450: 26.0.90; No check for nil in some filenotify functions
  2018-01-11  9:13       ` Michael Albinus
@ 2018-02-05  6:48         ` John Wiegley
  2018-02-05  7:45           ` Michael Albinus
  0 siblings, 1 reply; 7+ messages in thread
From: John Wiegley @ 2018-02-05  6:48 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 29450

>>>>> "MA" == Michael Albinus <michael.albinus@gmx.de> writes:

MA> I have the feeling that it isn't the return value of
MA> `find-file-name-handler' being nil, but rather the
MA> `file-notify--watch-directory' call.

I've had file-notify back on for a few days now, and this has not happened
again, so I'm fine with closing this issue.

However -- and this is a separate bug -- I had to disable it again because it
was stalling out Emacs regularly. I'd ran an operation that changed the state
of the disk, and then Emacs would be locked up for minutes at a time until I
hit C-g repeatedly. Finally, I ran Instruments to see what was going on, and
it was stuck in a busy loop reading directories, spending 92% of its time
calling delq over and over again.

But that's a separate issue, and disabling file-notify cured the performance
problem.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#29450: 26.0.90; No check for nil in some filenotify functions
  2018-02-05  6:48         ` John Wiegley
@ 2018-02-05  7:45           ` Michael Albinus
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Albinus @ 2018-02-05  7:45 UTC (permalink / raw)
  To: John Wiegley; +Cc: 29450-done

John Wiegley <johnw@gnu.org> writes:

Hi John,

> I've had file-notify back on for a few days now, and this has not happened
> again, so I'm fine with closing this issue.

I do it herewith.

> However -- and this is a separate bug -- I had to disable it again because it
> was stalling out Emacs regularly. I'd ran an operation that changed the state
> of the disk, and then Emacs would be locked up for minutes at a time until I
> hit C-g repeatedly. Finally, I ran Instruments to see what was going on, and
> it was stuck in a busy loop reading directories, spending 92% of its time
> calling delq over and over again.

In function `file-notify-handle-event', there's a commented `message'
call. Could you enable this, and send the output when this problem
happens, again?

> But that's a separate issue, and disabling file-notify cured the performance
> problem.

Do you write another bug report for this?

Best regards, Michael.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-02-05  7:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-26  6:18 bug#29450: 26.0.90; No check for nil in some filenotify functions John Wiegley
2017-11-26 15:39 ` Eli Zaretskii
2018-01-10  0:28   ` Glenn Morris
2018-01-10 23:56     ` John Wiegley
2018-01-11  9:13       ` Michael Albinus
2018-02-05  6:48         ` John Wiegley
2018-02-05  7:45           ` Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).