Message ID | CAF5HaEU+9uQn=P37F=c8WxausmA3BPL9SKXoTVZh+2SNA1V1cw@mail.gmail.com |
---|---|
State | Committed |
Headers |
Return-Path: <x14314964@homiemail-mx23.g.dreamhost.com> 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 648333600DB for <siddhesh@wilcox.dreamhost.com>; Thu, 20 Mar 2014 09:33:45 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14314964) id E6CD562BF3CE8; Thu, 20 Mar 2014 09:33:44 -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 C377F62BBA80F for <gdb@patchwork.siddhesh.in>; Thu, 20 Mar 2014 09:33:44 -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:mime-version:date:message-id:subject:from:to :content-type; q=dns; s=default; b=at7JLk/+J1bAfptqljpT6TZDz++31 3GwsmAOV+QHPzffjWZIwJmXDgrXIPqeAFGB+qZrhu9SQ38DtOA/yeSNx+/LA0OeN JOKd/HqflgRljLP8FZay6KgfC5blIYZQswf+4SR1Mq2ImVW5YPUMm8IpBoecBvjO JtFNWcl90u8aH8= 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:mime-version:date:message-id:subject:from:to :content-type; s=default; bh=QcHj0gGwFKxSIo/eKhqzXPELKvs=; b=p6F xUHIXBF/3e23JueGJ9RqNW3Jy6Uc2FuYPvRirME9YtDlbNobDAlmh7vDlyKpTUfz YxHNg+KV5YQuyuO5s7TuC2e755jGkh6rzJKjHfCfCfYJ4zUV8BNacNjO5OidjGca dLDHTldK5zJIoHBQF/2r3tGoC9L9fl+YNL9HxD/w= Received: (qmail 6684 invoked by alias); 20 Mar 2014 16:33:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-gdb=patchwork.siddhesh.in@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 6406 invoked by uid 89); 20 Mar 2014 16:33:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: mail-la0-f47.google.com Received: from mail-la0-f47.google.com (HELO mail-la0-f47.google.com) (209.85.215.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 20 Mar 2014 16:33:26 +0000 Received: by mail-la0-f47.google.com with SMTP id y1so796360lam.6 for <gdb-patches@sourceware.org>; Thu, 20 Mar 2014 09:33:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=MBMYNrZj3YTLJjyuOWRFmmB/8r2LNRkeBMoIDMuxILM=; b=m8Yj0ByYzC8uGSWdZzOADqyLgl1vJ5tUjo8c+6Yph9yDT6wyxXW186H6rQuQgQYXF1 WEd9JUuPgF1q7hXxajmaDKFYOufPR/ncHQXUJIMWjbjapySGu53ntlX0wa8KdXquykgN gFoAAti+HHES9ozv3XYDBk/UAiTY3AhmhLS7+WSd39mDQW9FIkPqXMMqPDEFlxh41RtP cpAkvapXqiUuR2KncQzLIrlBQp1X0vVUgk+/qsXY5expRPa/5dWFdUhkBrxSEEEhUbha koFhwE7iRs4hYLBNM3SmFFNdZ/lglrHA+11gofN550zKcYsAkuhYlbnQx0P02M6flBY3 3BXw== X-Gm-Message-State: ALoCoQkuh5uXa4G5s17xbeZMIkhKtphSsSRYqWaxmXZTiBpbKYHuX/1WMQGQH/1LE39aNlyAdGQd MIME-Version: 1.0 X-Received: by 10.153.5.33 with SMTP id cj1mr79275lad.65.1395333203052; Thu, 20 Mar 2014 09:33:23 -0700 (PDT) Received: by 10.112.9.40 with HTTP; Thu, 20 Mar 2014 09:33:22 -0700 (PDT) Date: Thu, 20 Mar 2014 13:33:22 -0300 Message-ID: <CAF5HaEU+9uQn=P37F=c8WxausmA3BPL9SKXoTVZh+2SNA1V1cw@mail.gmail.com> Subject: [PATCH] Small segfault fix when there is no python From: Daniel Gutson <daniel.gutson@tallertechnologies.com> To: gdb-patches@sourceware.org Content-Type: multipart/mixed; boundary=001a11349628e9706e04f50c5399 X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in |
Commit Message
Daniel Gutson
March 20, 2014, 4:33 p.m. UTC
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. Please commit it for me if approved since I don't have write access. Thanks, Daniel. 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.
Comments
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 <your@email> * 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,
On Thu, Mar 20, 2014 at 10:31 AM, Sergio Durigan Junior <sergiodj@redhat.com> 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 <your@email> > > * 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!
Thanks Doug and Sergio! Daniel. On Thu, Mar 20, 2014 at 2:52 PM, Doug Evans <dje@google.com> wrote: > On Thu, Mar 20, 2014 at 10:31 AM, Sergio Durigan Junior > <sergiodj@redhat.com> 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 <your@email> >> >> * 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!
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; + } + } /* The requested extension language is not supported in this GDB. */ throw_ext_lang_unsupported (extlang); }