Received: from eggs.gnu.org ([140.186.70.92]:50824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSA5s-0007HV-Jb for qemu-devel@nongnu.org; Sun, 20 Nov 2011 11:18:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RSA5r-0003Rp-DC for qemu-devel@nongnu.org; Sun, 20 Nov 2011 11:18:12 -0500 Received: from cantor2.suse.de ([195.135.220.15]:45048 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSA5r-0003Ra-3r for qemu-devel@nongnu.org; Sun, 20 Nov 2011 11:18:11 -0500 Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Alexander Graf In-Reply-To: Date: Sun, 20 Nov 2011 17:18:08 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <505BE786-7436-4676-BAB8-DC04DE1ADF49@suse.de> References: <1321790786-28518-1-git-send-email-agraf@suse.de> Subject: Re: [Qemu-devel] [PATCH] linux-user: fix QEMU_STRACE=1 segfault List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: riku.voipio@iki.fi, qemu-devel Developers On 20.11.2011, at 16:31, Peter Maydell wrote: > On 20 November 2011 12:06, Alexander Graf wrote: >> --- a/linux-user/syscall.c >> +++ b/linux-user/syscall.c >> @@ -711,6 +711,9 @@ static inline int host_to_target_errno(int err) >>=20 >> static inline int target_to_host_errno(int err) >> { >> + if (err >=3D ERRNO_TABLE_SIZE) { >> + return err; >> + } >> if (target_to_host_errno_table[err]) >> return target_to_host_errno_table[err]; >> return err; >=20 > Really strace shouldn't be assuming all negative values > are errnos: the code has a "print in one format for errnos, > print in another if we're assuming it's an address", so we > should have a way for the stracing code to be making the > right "errno or not?" decision, so we can print these normal > return values properly. Yep. I don't want to have to trace segfaults when it goes wrong though = :). > Since target_to_host_errno() is only used by target_strerror() > and target_strerror() is only used by the strace code we should > just change its API to something easier for the strace code to > use. How about having target_strerror() return NULL for "this > doesn't look like an errno", and then the strace layer prints > the plain address or "address (errno string)" accordingly? I like that idea, yup. > OTOH host_to_target_errno() could probably use a bounds check. Maybe I'm too spoiled by JITed programming languages, but I really like = it when array accessor functions check for sanity. I don't mind if we = assert() it though, so the bug is easier to spot next time around. Alex