From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: valid_pointer_p Date: Sun, 30 Jul 2006 06:16:51 +0300 Message-ID: References: Reply-To: Eli Zaretskii NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1154229428 6102 80.91.229.2 (30 Jul 2006 03:17:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 30 Jul 2006 03:17:08 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 30 05:17:06 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 1G71ne-0006Oo-51 for ged-emacs-devel@m.gmane.org; Sun, 30 Jul 2006 05:17:06 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G71nd-00071z-Ku for ged-emacs-devel@m.gmane.org; Sat, 29 Jul 2006 23:17:05 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G71nT-00071t-4n for emacs-devel@gnu.org; Sat, 29 Jul 2006 23:16:55 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G71nQ-00071h-KO for emacs-devel@gnu.org; Sat, 29 Jul 2006 23:16:53 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G71nQ-00071e-GA for emacs-devel@gnu.org; Sat, 29 Jul 2006 23:16:52 -0400 Original-Received: from [192.114.186.66] (helo=romy.inter.net.il) by monty-python.gnu.org with esmtp (Exim 4.52) id 1G71pm-0000qG-24 for emacs-devel@gnu.org; Sat, 29 Jul 2006 23:19:18 -0400 Original-Received: from HOME-C4E4A596F7 (IGLD-80-230-70-73.inter.net.il [80.230.70.73]) by romy.inter.net.il (MOS 3.7.3-GA) with ESMTP id FJV43717 (AUTH halo1); Sun, 30 Jul 2006 06:16:49 +0300 (IDT) Original-To: storm@cua.dk (Kim F. Storm) In-reply-to: (storm@cua.dk) 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:57801 Archived-At: > 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? Should we ask people to try that on different platforms? It goes without saying that on MS-Windows, the code does segfault if the argument is an invalid pointer. 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.)