pcp
[Top] [All Lists]

python pmExtractValue segfault

To: pcp@xxxxxxxxxxx
Subject: python pmExtractValue segfault
From: Michele Baldessari <michele@xxxxxxxxxx>
Date: Tue, 27 May 2014 23:30:45 +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=1401229845; bh=XaefUyOwwLVJj7GbjD4 eRRiuW9RPfXstxa96Kwd2BEE=; b=cwC0bUilZRZQhg+7WFrF7Lr+9CJ4rCQDglQ ZstAX0MFVznibzPJDeXrYbM2rap4T0EiexakLsLuWITXnvwv6n1kdU49u1eIA8ca irvua5owZadKOrqyz37EhztLQwrOGQviEwNJEEm8mzbIQELkp+PkrICX3Nckvodm Is/Trh68=
User-agent: Mutt/1.5.21 (2012-12-30)
Hi Nathan and all,

I've attached a simple script that given an archive file, walks through
each metric and does a pmFetch()/pmSetMode(c_api.PM_MODE_FORW, start, 0) 
loop. The goal of the function is to return data in the following form:
return = {}
return[metric1] = {'indom1': [(ts0, ts1, .., tsN), (v0, v1, .., vN)],
                   ....
                   'indomN': [(ts0, ts1, .., tsN), (v0, v1, .., vN)]}
return[metric2] = {'indom1': [(ts0, ts1, .., tsX), (v0, v1, .., vX)],
                   ....
                   'indomN': [(ts0, ts1, .., tsX), (v0, v1, .., vX)]}

When I run the script against this archive [1] I end up segfaulting:
Program received signal SIGSEGV, Segmentation fault.
0x0000003d2e4213d4 in pmExtractValue (valfmt=1, ival=<optimized out>, itype=3, 
oval=0x75df40, otype=3) at units.c:794
794                     if (ival->value.pval->vlen != PM_VAL_HDR_SIZE + 
sizeof(__uint64_t) ||

The crash is due because pmExtractValue() segfaults when the indom list
changes. While I am fixing this by using using contents.get_numval()
to loop over all the values with pmExtractValue() [as opposed to using
the length of the instances returned by pmGetInDomArchive()], I was
wondering if there is a better way in general to achieve my goal here
(retrieve all values/indoms for all metrics for all timestamps).

Maybe it makes sense to make pmExtractValue fail gracefully in any case?

Cheers,
Michele

[1] 
https://github.com/mbaldessari/pcpstats/blob/master/tests/pcp-files/server1.internal/20140510.08.47.0
-- 
Michele Baldessari            <michele@xxxxxxxxxx>
C2A5 9DA3 9961 4FFB E01B  D0BC DDD4 DCCB 7515 5C6D

Attachment: fetch-indom2.py
Description: Text document

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