Bug 13331

Summary: (cpychecker) Segfault in gdb/python/py-function.c:convert_values_to_python under low memory conditions
Product: gdb Reporter: Dave Malcolm <dmalcolm>
Component: pythonAssignee: Phil Muldoon <pmuldoon>
Status: RESOLVED FIXED    
Severity: normal CC: pmuldoon
Priority: P2    
Version: HEAD   
Target Milestone: 7.4   
Host: Target:
Build: Last reconfirmed:
Attachments: HTML report showing the execution paths that can crash

Description Dave Malcolm 2011-10-21 21:21:38 UTC
Created attachment 6025 [details]
HTML report showing the execution paths that can crash

convert_values_to_python doesn't check the return value from PyTuple_New, which can return NULL under low memory conditions.

If it returns NULL and argc > 0 then there are two different segfaults possible; see attached HTML.
Comment 1 Sourceware Commits 2011-10-27 10:30:02 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	pmuldoon@sourceware.org	2011-10-27 10:29:58

Modified files:
	gdb            : ChangeLog 
	gdb/python     : py-function.c 

Log message:
	2011-10-27  Phil Muldoon  <pmuldoon@redhat.com>
	
	PR python/13331
	
	* python/py-function.c (fnpy_call): Check 'args' is not NULL.
	(convert_values_to_python): Return on Python tuple allocation
	failure.  Return NULL on value conversion error.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.13464&r2=1.13465
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/py-function.c.diff?cvsroot=src&r1=1.10&r2=1.11
Comment 2 Phil Muldoon 2011-10-27 10:31:52 UTC
Fixed and committed.