Bug 666660

Summary: inadequate parenthesization in systemtap probe macros
Product: [Fedora] Fedora Reporter: Tom Lane <tgl>
Component: systemtapAssignee: Frank Ch. Eigler <fche>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 13CC: fche, hhorak, jistone, roland, scox
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-04-24 15:09:10 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tom Lane 2011-01-02 00:45:10 UTC
Description of problem:
Source code like this:
	TRACE_POSTGRESQL_SORT_DONE(state->tapeset != NULL, spaceUsed);
produces this warning:
        tuplesort.c:843: warning: comparison between pointer and integer
Investigation shows that the macro is expanding to
        do { size_t arg1 = (size_t)state->tapeset != ((void *)0); ...
so obviously the problem is failure to parenthesize the macro argument.

In this particular case it manages to give the right runtime behavior anyway,
but in other cases it would yield an outright wrong value for the probe
argument.

Version-Release number of selected component (if applicable):
systemtap-sdt-devel-1.3-3.fc13.x86_64

Additional info:
The probe definition is
	probe sort__done(bool, long);
though I'm not sure that matters.

Comment 1 Frank Ch. Eigler 2011-01-03 21:08:12 UTC
Can you check whether changing /usr/include/sys/sdt.h
by adding parentheses in these two places works for you?

67: #define STAP_CAST(t) (t)
83: #define STAP_CAST(t) (size_t)(t)

Stan, can you audit git systemtap's sdt.h also, to make sure
that incoming parameter expressions are parenthesized?  The
_SDT_PROBE() calls in #define STAP_PROBE... near line 200+
appear to lack this.

Comment 2 Tom Lane 2011-01-03 21:29:11 UTC
I confirm those changes silence the warning in Postgres.  Personally I'd spell the latter macro as "((size_t) (t))", but maybe I'm just overly paranoid.

Comment 3 Frank Ch. Eigler 2011-04-24 15:09:10 UTC
systemtap-1.4 corrects this.