pcp
[Top] [All Lists]

Small python segfault fix when printing empty units structs

To: pcp@xxxxxxxxxxx
Subject: Small python segfault fix when printing empty units structs
From: Michele Baldessari <michele@xxxxxxxxxx>
Date: Sat, 24 May 2014 11:08:20 +0100
Delivered-to: pcp@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=acksyn.org; h= user-agent:content-disposition:content-type:content-type :mime-version:message-id:subject:subject:from:from:date:date :received:received; s=2010; t=1400926101; bh=ldwMusGimdgXVF8xsVf gf1alTP7JWqJrvpzxg+cbqq8=; b=deajeCzYhVtTAJfkgR6b2s7oPQtBxzi0tUe ofMv/HDQ+Rd1JiRxIMu0k6NZtT6UVLeSAQO1LulXUA5WAjlwu/9wFi1QxCJQ6V4t yG+JD0z8gHWOihRVKBeZcNUpC4O/xG6l2JcQXDIoQGrN6ljPrxDzjZOw7MI1q92h q6wdKUEM=
User-agent: Mutt/1.5.21 (2012-12-30)
Hi all,

on https://github.com/mbaldessari/pcp/tree/fix-python-pmunitsstr 
you can find a small fix for a segfault I stumbled upon while using
the python bindings.

Do let me know if this way of sending patches is ok ;)

regards,
Michele

commit a01a5c131d047b98b5aa0bd9917614ce69f7d764
Author: Michele Baldessari <michele@xxxxxxxxxx>
Date:   Sat May 24 11:00:55 2014 +0100

    Python - Fix segfault when printing empy units
    
    The following example:
    """
    import pcp.pmapi
    from pcp.pmapi import c_api
    
    fname = '20140506.0'
    context = pcp.pmapi.pmContext(c_api.PM_CONTEXT_ARCHIVE, fname)
    pmids = context.pmLookupName(['proc.nprocs'])
    descs = context.pmLookupDescs(pmids[0])
    print 'Segfault: %s' % descs[0].contents.units
    """
    
    will segfault:
    pmUnitsStr_r (pu=0x0, buf=buf@entry=0x3d2e66f9c0 <ubuf> "", 
buflen=buflen@entry=60) at units.c:177
    177         if (pu->dimSpace) {
    
    Make sure we wrap pmUnitsStr in order to catch these and correctly
    return an empty string


-- 
Michele Baldessari            <michele@xxxxxxxxxx>
C2A5 9DA3 9961 4FFB E01B  D0BC DDD4 DCCB 7515 5C6D

<Prev in Thread] Current Thread [Next in Thread>