From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: valid_pointer_p Date: Mon, 31 Jul 2006 00:13:26 +0200 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1154297726 24620 80.91.229.2 (30 Jul 2006 22:15:26 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 30 Jul 2006 22:15:26 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 31 00:15:22 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1G7JZ8-0000JH-MU for ged-emacs-devel@m.gmane.org; Mon, 31 Jul 2006 00:15:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G7JZ7-0006Ns-Kl for ged-emacs-devel@m.gmane.org; Sun, 30 Jul 2006 18:15:17 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G7JYu-0006L3-Tb for emacs-devel@gnu.org; Sun, 30 Jul 2006 18:15:04 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G7JYt-0006J6-MI for emacs-devel@gnu.org; Sun, 30 Jul 2006 18:15:04 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G7JYt-0006Is-HG for emacs-devel@gnu.org; Sun, 30 Jul 2006 18:15:03 -0400 Original-Received: from [195.41.46.236] (helo=pfepb.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.52) id 1G7JbO-00030a-Ca; Sun, 30 Jul 2006 18:17:38 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx3.adsl-dhcp.tele.dk [80.62.38.68]) by pfepb.post.tele.dk (Postfix) with SMTP id B98FBA50002; Mon, 31 Jul 2006 00:14:57 +0200 (CEST) Original-To: Eli Zaretskii In-Reply-To: (Eli Zaretskii's message of "Sun, 30 Jul 2006 06:16:51 +0300") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:57821 Archived-At: Eli Zaretskii writes: >> Cc: emacs-devel@gnu.org >> From: storm@cua.dk (Kim F. Storm) >> Date: Sun, 30 Jul 2006 02:05:25 +0200 >> >> Eli Zaretskii 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 http://www.cua.dk