From patchwork Sat Mar 22 07:02:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 233 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (caibbdcaabja.dreamhost.com [208.113.200.190]) by wilcox.dreamhost.com (Postfix) with ESMTP id B6F353600F2 for ; Sat, 22 Mar 2014 00:02:51 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14314964) id 4649C61CE1E8A; Sat, 22 Mar 2014 00:02:51 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx23.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx23.g.dreamhost.com (Postfix) with ESMTPS id 2438861CE1E71 for ; Sat, 22 Mar 2014 00:02:51 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type; q=dns; s=default; b=GovuI l34q49mWDI+qsm9XBMjP/UILOY7Lgu5FEBAooBxW0lATSIALnBgYQnJfmUMSI0aQ y0KPm9ly12NeKzM+JRSVNpPDq+AH7vY4mXNHgIzBUL8sbiCc9vuo+t88b1tvZwi3 wTcmgYffDO7PmEsl/UmaUX9dYoNtA4mGv6UaOg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type; s=default; bh=IdLJNdsgtn5 uuhJMBO4B/P3ZGGc=; b=QxRO2Xx8nI0S7Fwd7gB3akXVZbf8YTHSpYlwKumLzFh lO0ARDXVBp2fm89I93FChGFXijlv8hHADvzDfllr4H/mlTLakn8ARCYDGFLm9JWk 6OkwzIQKUvbG4tz9CMJTqqGBZdxFPwB7L2KGkCB/j2XHJTsSz9SBqTgpBtBeW8wY = Received: (qmail 15607 invoked by alias); 22 Mar 2014 07:02:48 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 15597 invoked by uid 89); 22 Mar 2014 07:02:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-pd0-f179.google.com Received: from mail-pd0-f179.google.com (HELO mail-pd0-f179.google.com) (209.85.192.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 22 Mar 2014 07:02:46 +0000 Received: by mail-pd0-f179.google.com with SMTP id w10so3231679pde.38 for ; Sat, 22 Mar 2014 00:02:44 -0700 (PDT) X-Received: by 10.68.234.2 with SMTP id ua2mr58221895pbc.81.1395471764508; Sat, 22 Mar 2014 00:02:44 -0700 (PDT) Received: from ruffy-vm.sspiff.org.gmail.com (173-13-178-50-sfba.hfc.comcastbusiness.net. [173.13.178.50]) by mx.google.com with ESMTPSA id ge7sm13805960pbc.61.2014.03.22.00.02.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Mar 2014 00:02:43 -0700 (PDT) From: Doug Evans To: Daniel Gutson Cc: Sergio Durigan Junior , gdb-patches Subject: Re: [PATCH] Small segfault fix when there is no python References: Date: Sat, 22 Mar 2014 03:02:43 -0400 In-Reply-To: (Daniel Gutson's message of "Fri, 21 Mar 2014 13:24:46 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in Daniel Gutson writes: > Thanks Doug and Sergio! > > Daniel. > > > On Thu, Mar 20, 2014 at 2:52 PM, Doug Evans wrote: >> On Thu, Mar 20, 2014 at 10:31 AM, Sergio Durigan Junior >> wrote: >>> On Thursday, March 20 2014, Daniel Gutson wrote: >>> >>>> Hi, >>>> >>>> the small attached patch prevents gdb to segfault when an extension >>>> language definition has no ops, >>>> which e.g. occurs when HAVE_PYTHON is not defined so >>>> extension_language_python remains with ops in NULL. >>>> This causes the line >>>> if (extlang->ops->eval_from_control_command != NULL) >>>> (in eval_ext_lang_from_control_command) to dereference a null pointer. >>> >>> Hi Daniel, >>> >>> Thanks for the patch. This is a simple patch so it doesn't need a >>> copyright assignment from you. However, if you intend to continue >>> contributing to GDB, please e-mail me offlist and I can send you the >>> papers to obtain the assignment. >>> >>> Just a few comments about formatting issues. >>> >>>> 2014-03-20 Daniel Gutson (daniel.gutson@tallertechnologies.com) >>>> >>>> gdb/ >>>> * extension.c: (eval_ext_lang_from_control_command) Added check to >>>> prevent dereference of null pointer. >>> >>> The ChangeLog format is wrong. Take a look at the ChangeLog file for >>> lots of examples, but basically you need to write: >>> >>> 2014-03-20 Your Name >>> >>> * file.c (function): Added check to prevent blabla... >>> >>> Pay attention to the 2 spaces between the date, the name and the e-mail, >>> and also to the TAB character indenting the description. >>> >>>> diff --git a/gdb/extension.c b/gdb/extension.c >>>> index c2f502b..8357ee8 100644 >>>> --- a/gdb/extension.c >>>> +++ b/gdb/extension.c >>>> @@ -342,11 +342,14 @@ eval_ext_lang_from_control_command (struct command_line *cmd) >>>> { >>>> if (extlang->cli_control_type == cmd->control_type) >>>> { >>>> - if (extlang->ops->eval_from_control_command != NULL) >>>> - { >>>> - extlang->ops->eval_from_control_command (extlang, cmd); >>>> - return; >>>> - } >>>> + if (extlang->ops != NULL) >>>> + { >>>> + if (extlang->ops->eval_from_control_command != NULL) >>>> + { >>>> + extlang->ops->eval_from_control_command (extlang, cmd); >>>> + return; >>>> + } >>>> + } >>> >>> You could simplify this by writing: >>> >>> if (extlang->ops != NULL && >>> extlang->ops->eval_from_control_command != NULL) >>> >>> If you don't want to join the two "if"s, then you don't need to put the >>> braces on the outter "if", because it has one single statement. >>> >>> The patch looks good to me, but I'm not a maintainer and can't approve >>> it. >>> >>> Thanks, >>> >>> -- >>> Sergio >> >> >> I did an audit of all the uses of ->ops and think this is the only >> one I missed. >> I will commit with the needed changes. >> Thanks for the patch! Here's what I committed. I added a testcase. 2014-03-21 Daniel Gutson * extension.c (eval_ext_lang_from_control_command): Avoid dereferencing NULL pointer. testsuite/ 2014-03-22 Doug Evans * gdb.python/python.exp (python not supported): Verify multi-line python command issues an error. * gdb.guile/guile.exp (guile not supported): Verify multi-line guile command issues an error. diff --git a/gdb/extension.c b/gdb/extension.c index c2f502b..1146cc7 100644 --- a/gdb/extension.c +++ b/gdb/extension.c @@ -342,7 +342,8 @@ eval_ext_lang_from_control_command (struct command_line *cmd) { if (extlang->cli_control_type == cmd->control_type) { - if (extlang->ops->eval_from_control_command != NULL) + if (extlang->ops != NULL + && extlang->ops->eval_from_control_command != NULL) { extlang->ops->eval_from_control_command (extlang, cmd); return; diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index a470427..5b8d34a 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -41,6 +41,13 @@ gdb_test_multiple "python print (23)" "verify python support" { gdb_test "source $srcdir/$subdir/source2.py" \ "Error in sourced command file:.*" \ "source source2.py when python disabled" + + # Verify multi-line python commands cause an error. + gdb_py_test_multiple "multi-line python command" \ + "python" "" \ + "print (23)" "" \ + "end" "not supported.*" + return -1 } -re "$gdb_prompt $" {} diff --git a/gdb/testsuite/gdb.guile/guile.exp b/gdb/testsuite/gdb.guile/guile.exp index 2a171fe..f300d72 100644 --- a/gdb/testsuite/gdb.guile/guile.exp +++ b/gdb/testsuite/gdb.guile/guile.exp @@ -38,6 +38,13 @@ gdb_test_multiple "guile (display 23) (newline)" "verify guile support" { gdb_test "source $srcdir/$subdir/source2.scm" \ "Error in sourced command file:.*" \ "source source2.scm when guile disabled" + + # Verify multi-line guile commands cause an error. + gdb_test_multiline "multi-line guile command" \ + "guile" "" \ + "(print 23)" "" \ + "end" "not supported.*" + return } -re "$gdb_prompt $" {}