* [PATCH] Small segfault fix when there is no python
@ 2014-03-20 16:33 Daniel Gutson
2014-03-20 17:31 ` Sergio Durigan Junior
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Gutson @ 2014-03-20 16:33 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 639 bytes --]
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.
[-- Attachment #2: python.patch --]
[-- Type: text/x-patch, Size: 768 bytes --]
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);
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Small segfault fix when there is no python
2014-03-20 16:33 [PATCH] Small segfault fix when there is no python Daniel Gutson
@ 2014-03-20 17:31 ` Sergio Durigan Junior
2014-03-20 17:52 ` Doug Evans
0 siblings, 1 reply; 5+ messages in thread
From: Sergio Durigan Junior @ 2014-03-20 17:31 UTC (permalink / raw)
To: Daniel Gutson; +Cc: gdb-patches
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Small segfault fix when there is no python
2014-03-20 17:31 ` Sergio Durigan Junior
@ 2014-03-20 17:52 ` Doug Evans
2014-03-21 16:24 ` Daniel Gutson
0 siblings, 1 reply; 5+ messages in thread
From: Doug Evans @ 2014-03-20 17:52 UTC (permalink / raw)
To: Sergio Durigan Junior; +Cc: Daniel Gutson, gdb-patches
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!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Small segfault fix when there is no python
2014-03-20 17:52 ` Doug Evans
@ 2014-03-21 16:24 ` Daniel Gutson
2014-03-22 7:02 ` Doug Evans
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Gutson @ 2014-03-21 16:24 UTC (permalink / raw)
To: Doug Evans; +Cc: Sergio Durigan Junior, gdb-patches
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!
--
Daniel F. Gutson
Chief Engineering Officer, SPD
San Lorenzo 47, 3rd Floor, Office 5
Córdoba, Argentina
Phone: +54 351 4217888 / +54 351 4218211
Skype: dgutson
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Small segfault fix when there is no python
2014-03-21 16:24 ` Daniel Gutson
@ 2014-03-22 7:02 ` Doug Evans
0 siblings, 0 replies; 5+ messages in thread
From: Doug Evans @ 2014-03-22 7:02 UTC (permalink / raw)
To: Daniel Gutson; +Cc: Sergio Durigan Junior, gdb-patches
Daniel Gutson <daniel.gutson@tallertechnologies.com> writes:
> 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!
Here's what I committed.
I added a testcase.
2014-03-21 Daniel Gutson <daniel.gutson@tallertechnologies.com>
* extension.c (eval_ext_lang_from_control_command): Avoid dereferencing
NULL pointer.
testsuite/
2014-03-22 Doug Evans <xdje42@gmail.com>
* 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 $" {}
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-03-22 7:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-20 16:33 [PATCH] Small segfault fix when there is no python Daniel Gutson
2014-03-20 17:31 ` Sergio Durigan Junior
2014-03-20 17:52 ` Doug Evans
2014-03-21 16:24 ` Daniel Gutson
2014-03-22 7:02 ` Doug Evans
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox