all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
Cc: emacs-devel@gnu.org
Subject: Re: valid_pointer_p
Date: Mon, 31 Jul 2006 00:13:26 +0200	[thread overview]
Message-ID: <m3d5bm4u7t.fsf@kfs-l.imdomain.dk> (raw)
In-Reply-To: <uirlfbx3w.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 30 Jul 2006 06:16:51 +0300")

Eli Zaretskii <eliz@gnu.org> writes:

>> Cc: emacs-devel@gnu.org
>> From: storm@cua.dk (Kim F. Storm)
>> Date: Sun, 30 Jul 2006 02:05:25 +0200
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> > Can someone ``in the know'' please explain what clever idea is behind
>> > the function valid_pointer_p, and whether that idea is supposed to be
>> > portable?  
>> 
>> If you have some better way to do this on some platforms, please tell me.
>
> Well, I really don't understand what are the assumptions of the code.
> Are you assuming that accessing an invalid pointer inside a system
> call (such as `read') will never segfault?  Does Posix really mandate
> that?  

On the Linux kernel, write returns -1 with errno == EFAULT if the
provided buffer is invalid.

But, POSIX write spec does not say anything about invalid buffer or EFAULT.
So, indeed the current code is not portable.

>       Should we ask people to try that on different platforms?

IMO, it is not worth it.  This is a rare corner case.

> It goes without saying that on MS-Windows, the code does segfault if
> the argument is an invalid pointer.

.. but that's no worse than before I added pp / safe_debug_print.

And do people usually debug emacs with GDB on windows?

>
> As for other ways, we could, for example, set up a temporary signal
> handler for SIGSEGV around the call to valid_pointer_p.  That should
> work on most, if not all, supported platforms.
>
> Then there's the procfs API, which probably lets you actually read
> from the process memory on those platforms where procfs is available.
>
> On Windows, we could try reading from the address using the
> ReadProcessMemory API, which is used by debuggers.  (If ptrace allows
> reading from the calling process, we could do the same on Posix
> platforms.)

All of this sounds more or less complicated, but if someone want to
give one of these methods a try, fine with me.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

  reply	other threads:[~2006-07-30 22:13 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-29 10:27 valid_pointer_p Eli Zaretskii
2006-07-29 10:45 ` valid_pointer_p Andreas Schwab
2006-07-29 12:16   ` valid_pointer_p Eli Zaretskii
2006-07-30  0:05 ` valid_pointer_p Kim F. Storm
2006-07-30  3:16   ` valid_pointer_p Eli Zaretskii
2006-07-30 22:13     ` Kim F. Storm [this message]
2006-07-31  3:21       ` valid_pointer_p Eli Zaretskii
2006-07-31  8:30         ` valid_pointer_p Andreas Schwab
2006-07-31 17:10           ` valid_pointer_p Eli Zaretskii
2006-07-31 17:56             ` valid_pointer_p Andreas Schwab
2006-07-31  9:01         ` valid_pointer_p Kim F. Storm
2006-08-05 13:04           ` valid_pointer_p Eli Zaretskii
2006-08-05 13:09             ` valid_pointer_p Eli Zaretskii
2006-08-05 22:11             ` valid_pointer_p Kim F. Storm
2006-08-06  3:29               ` valid_pointer_p Eli Zaretskii
2006-08-11 22:58                 ` valid_pointer_p Kim F. Storm
2006-08-12 11:06                   ` valid_pointer_p Eli Zaretskii
2006-08-12 12:36                     ` valid_pointer_p Andreas Schwab
2006-08-12 14:39                       ` valid_pointer_p Eli Zaretskii
2006-08-12 20:19                         ` valid_pointer_p Kim F. Storm
2006-08-12 21:56                           ` valid_pointer_p Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3d5bm4u7t.fsf@kfs-l.imdomain.dk \
    --to=storm@cua.dk \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.