unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* No GCPRO in directory-files and directory-files-and-attributes
@ 2003-12-01 22:32 Lars Hansen
  2003-12-09 21:49 ` Richard Stallman
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Hansen @ 2003-12-01 22:32 UTC (permalink / raw)


In dired.c I have noticed that file name handlers are called using the
function call<n> from eval.c. However, there are two exceptions, the
calls in functions Fdirectory-files and Fdirectory-files-and-attributes
where Ffuncall is used instead. This means that the arguments are not
protected with GCPRO. Is this intensional or is it a bug? To me it looks
like a bug, but I may be missing something.

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

* Re: No GCPRO in directory-files and directory-files-and-attributes
  2003-12-01 22:32 No GCPRO in directory-files and directory-files-and-attributes Lars Hansen
@ 2003-12-09 21:49 ` Richard Stallman
  2003-12-10 18:45   ` Lars Hansen
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Stallman @ 2003-12-09 21:49 UTC (permalink / raw)
  Cc: emacs-devel

    In dired.c I have noticed that file name handlers are called using the
    function call<n> from eval.c. However, there are two exceptions, the
    calls in functions Fdirectory-files and Fdirectory-files-and-attributes
    where Ffuncall is used instead. This means that the arguments are not
    protected with GCPRO.

Calling call1 etc. does not GCPRO the variables from which the
argument values are obtained, any more than calling Ffuncall does.
When calling Ffuncall, you need to GCPRO the vector of arguments,
but only if the values are live.

			  Is this intensional or is it a bug?

I don't think there is a bug.  Those values will never be used again,
so they don't need to be GCPRO'd.

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

* Re: No GCPRO in directory-files and directory-files-and-attributes
  2003-12-09 21:49 ` Richard Stallman
@ 2003-12-10 18:45   ` Lars Hansen
  2003-12-22  4:08     ` Richard Stallman
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Hansen @ 2003-12-10 18:45 UTC (permalink / raw)
  Cc: emacs-devel

>
>
>Calling call1 etc. does not GCPRO the variables from which the
>argument values are obtained, any more than calling Ffuncall does.
>
Well, I don't know much about these things, but these lines are from call1:

    args[0] = fn;
    args[1] = arg1;
    GCPRO1 (args[0]);
    gcpro1.nvars = 2;
    RETURN_UNGCPRO (Ffuncall (2, args));

To me it looks as the arguments are protcted.

>I don't think there is a bug.  Those values will never be used again,
>so they don't need to be GCPRO'd.
>  
>
In eval.c there is the following comment:

    /* NOTE!!! Every function that can call EVAL must protect its args
       and temporaries from garbage collection while it needs them.
       The definition of `For' shows what you have to do.  */

When directory-files and directory-files-and-attributes call file name 
handlers I think eval may be called.
So to me it still looks like a bug. Am I missing something?

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

* Re: No GCPRO in directory-files and directory-files-and-attributes
  2003-12-10 18:45   ` Lars Hansen
@ 2003-12-22  4:08     ` Richard Stallman
  2003-12-22  7:22       ` Lars Hansen
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Stallman @ 2003-12-22  4:08 UTC (permalink / raw)
  Cc: emacs-devel

    Well, I don't know much about these things, but these lines are from call1:

	args[0] = fn;
	args[1] = arg1;
	GCPRO1 (args[0]);
	gcpro1.nvars = 2;
	RETURN_UNGCPRO (Ffuncall (2, args));

    To me it looks as the arguments are protcted.

Yes, I now recall you are right--whoever calls Ffuncall
needs to GCPRO the vector of args.

How about this patch?

*** dired.c.~1.106.~	Fri Nov 28 15:55:07 2003
--- dired.c	Sun Dec 21 23:15:55 2003
***************
*** 359,375 ****
       call the corresponding file handler.  */
    handler = Ffind_file_name_handler (directory, Qdirectory_files);
    if (!NILP (handler))
!     {
!       Lisp_Object args[6];
! 
!       args[0] = handler;
!       args[1] = Qdirectory_files;
!       args[2] = directory;
!       args[3] = full;
!       args[4] = match;
!       args[5] = nosort;
!       return Ffuncall (6, args);
!     }
  
    return directory_files_internal (directory, full, match, nosort, 0, Qnil);
  }
--- 359,366 ----
       call the corresponding file handler.  */
    handler = Ffind_file_name_handler (directory, Qdirectory_files);
    if (!NILP (handler))
!     return call5 (handler, Qdirectory_files, directory,
! 		  full, match, nosort);
  
    return directory_files_internal (directory, full, match, nosort, 0, Qnil);
  }
***************
*** 395,412 ****
       call the corresponding file handler.  */
    handler = Ffind_file_name_handler (directory, Qdirectory_files_and_attributes);
    if (!NILP (handler))
!     {
!       Lisp_Object args[7];
! 
!       args[0] = handler;
!       args[1] = Qdirectory_files_and_attributes;
!       args[2] = directory;
!       args[3] = full;
!       args[4] = match;
!       args[5] = nosort;
!       args[6] = id_format;
!       return Ffuncall (7, args);
!     }
  
    return directory_files_internal (directory, full, match, nosort, 1, id_format);
  }
--- 386,393 ----
       call the corresponding file handler.  */
    handler = Ffind_file_name_handler (directory, Qdirectory_files_and_attributes);
    if (!NILP (handler))
!     return call6 (handler, Qdirectory_files_and_attributes,
! 		  directory, full, match, nosort, id_format);
  
    return directory_files_internal (directory, full, match, nosort, 1, id_format);
  }

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

* Re: No GCPRO in directory-files and directory-files-and-attributes
  2003-12-22  4:08     ` Richard Stallman
@ 2003-12-22  7:22       ` Lars Hansen
  0 siblings, 0 replies; 5+ messages in thread
From: Lars Hansen @ 2003-12-22  7:22 UTC (permalink / raw)
  Cc: emacs-devel

>
>
>How about this patch?
>
I agree. Actually I was just about to apply that change myself when 
savannah was taken down.

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

end of thread, other threads:[~2003-12-22  7:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-01 22:32 No GCPRO in directory-files and directory-files-and-attributes Lars Hansen
2003-12-09 21:49 ` Richard Stallman
2003-12-10 18:45   ` Lars Hansen
2003-12-22  4:08     ` Richard Stallman
2003-12-22  7:22       ` Lars Hansen

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).