Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NrF9a-0006HK-Tm for qemu-devel@nongnu.org; Mon, 15 Mar 2010 14:36:38 -0400 Received: from [199.232.76.173] (port=56183 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NrF9a-0006GM-EP for qemu-devel@nongnu.org; Mon, 15 Mar 2010 14:36:38 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NrF9Y-0002gO-Ml for qemu-devel@nongnu.org; Mon, 15 Mar 2010 14:36:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6737) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NrF9Y-0002gA-9u for qemu-devel@nongnu.org; Mon, 15 Mar 2010 14:36:36 -0400 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH, RFC] Replace assert(0) with abort() or cpu_abort() References: Date: Mon, 15 Mar 2010 19:36:30 +0100 In-Reply-To: (Blue Swirl's message of "Mon, 15 Mar 2010 19:23:29 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: qemu-devel Blue Swirl writes: > On 3/15/10, Markus Armbruster wrote: >> Blue Swirl writes: >> >> > When building with -DNDEBUG, assert(0) will not stop execution >> > so it must not be used for abnormal termination. >> >> >> For each case: are you sure the code does not recover after assert(0)? >> Not saying it does, just asking whether you checked. > > I had not checked but did just now, > > QEMU system emulators do not handle SIGABRT. The situation is > different for user emulator, but then assert(0) and abort() would be > equally correct or incorrect. Please don't tell me that user emulators make abort() return. abort() is declared __noreturn__, and the optimizer may well rely on that. >> > Use cpu_abort() when in CPU context, abort() otherwise. >> >> >> I sympathize with the general idea, but I don't like dead code after >> abort(). What about cleaning that up? > > Good idea, but it should be a separate patch. This patch is "safe", > whereas the cleanup patch could cause problems if it's not done > carefully. I support keeping separate things separate. However, separating something like if (mapping->first_mapping_index != first_mapping_index && mapping->info.file.offset > 0) { - assert(0); + abort(); copy_it = 1; } from if (mapping->first_mapping_index != first_mapping_index && mapping->info.file.offset > 0) { abort(); - copy_it = 1; } doesn't seem worth it.