> So "avoid multiword type names" is both too general and not enough
> to keep out of trouble. [...] I'm inclined to write something like
> "Use only system-supplied type names, e.g., write uint64_t not uint64;
> macOS' dtrace rejects the latter.  Also avoid "long long int", as
> SystemTap's dtrace fails on that specific spelling."

I've
rewritten the probes.d note along those lines and kept ssize_t/size_t
for the smgr probes (system-supplied, matching md.c).

Updated patch attached.

ср, 29 июл. 2026 г. в 20:42, Tom Lane <[email protected]>:

> Andrey Rachitskiy <[email protected]> writes:
> > On the probes.d note: it originally named Mac OS X 10.5 (e04810e8c4).
> > The concrete complaints from that era were about uintptr_t / uint32_t
> > and about needing #define rather than typedef for our PG aliases
> > (Robert Lor).
>
> I poked at this some more.  On macOS Tahoe, both examples called out
> in the current text (uintptr_t, uint32_t) work fine, as does "long
> long int", as does uint64_t, but not uint64.  On Red Hat platforms at
> least as far back as RHEL 9 and as late as Fedora 43, "long long int"
> doesn't work (matching the buildfarm reports), but "long int" does,
> and so does "unsigned int", and so does "long long" (!), and so do
> both uint64_t and uint64.
>
> So "avoid multiword type names" is both too general and not enough
> to keep out of trouble.  It's not clear to me that we can come up
> with a simple rule of thumb.  We clearly should recommend against
> using non-system-supplied type names, since it looks like macOS
> has a whitelist of valid type names.  But the Linux implementation
> seems to be missing specifically "long long int".
>
> I'm inclined to write something like "Use only system-supplied type
> names, e.g., write uint64_t not uint64; macOS' dtrace rejects the
> latter.  Also avoid "long long int", as SystemTap's dtrace fails on
> that specific spelling."  We can add other problems as we hit them,
> but let's not warn people away from cases we've not tested.
>
>                         regards, tom lane
>
From a4a67e08ff1c72fefb23d2fd22f2afb5efab358f Mon Sep 17 00:00:00 2001
From: Andrey Rachitskiy <[email protected]>
Date: Wed, 29 Jul 2026 21:04:53 +0500
Subject: [PATCH] Fix SystemTap dtrace warning for smgr probe argument types

Commits ca326e903d and 1f8c504e308 widened the byte-count arguments of
smgr__md__read__done and smgr__md__write__done to "long long int".
SystemTap's dtrace(1) fails on that specific spelling and falls back
with a warning (misreported near the previous probe).  Use ssize_t and
size_t instead, matching the md.c call sites.  Revise the probes.d
note: prefer system-supplied type names (macOS dtrace rejects names
like PostgreSQL's uint64), and call out "long long int" as a known
SystemTap failure rather than a blanket multi-word ban.

Author: Andrey Rachitskiy <[email protected]>
Reported-by: Laurenz Albe <[email protected]>
Discussion: https://postgr.es/m/[email protected]
---
 doc/src/sgml/monitoring.sgml |  4 ++--
 src/backend/utils/probes.d   | 11 +++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml
index 074a821a68e..0c7107d400b 100644
--- a/doc/src/sgml/monitoring.sgml
+++ b/doc/src/sgml/monitoring.sgml
@@ -8595,7 +8595,7 @@ FROM pg_stat_get_backend_idset() AS backendid;
     </row>
     <row>
      <entry><literal>smgr-md-read-done</literal></entry>
-     <entry><literal>(ForkNumber, BlockNumber, Oid, Oid, Oid, int, int, int)</literal></entry>
+     <entry><literal>(ForkNumber, BlockNumber, Oid, Oid, Oid, int, ssize_t, size_t)</literal></entry>
      <entry>Probe that fires when a block read is complete.
       arg0 and arg1 contain the fork and block numbers of the page.
       arg2, arg3, and arg4 contain the tablespace, database, and relation OIDs
@@ -8617,7 +8617,7 @@ FROM pg_stat_get_backend_idset() AS backendid;
     </row>
     <row>
      <entry><literal>smgr-md-write-done</literal></entry>
-     <entry><literal>(ForkNumber, BlockNumber, Oid, Oid, Oid, int, int, int)</literal></entry>
+     <entry><literal>(ForkNumber, BlockNumber, Oid, Oid, Oid, int, ssize_t, size_t)</literal></entry>
      <entry>Probe that fires when a block write is complete.
       arg0 and arg1 contain the fork and block numbers of the page.
       arg2, arg3, and arg4 contain the tablespace, database, and relation OIDs
diff --git a/src/backend/utils/probes.d b/src/backend/utils/probes.d
index 2d8f12cbe30..b8a381d2f68 100644
--- a/src/backend/utils/probes.d
+++ b/src/backend/utils/probes.d
@@ -11,8 +11,11 @@
 /*
  * Typedefs used in PostgreSQL probes.
  *
- * NOTE: Do not use system-provided typedefs (e.g. uintptr_t, uint32_t, etc)
- * in probe definitions, as they cause compilation errors on macOS.
+ * NOTE: Prefer system-supplied type names in probe definitions (e.g.
+ * uint64_t, not PostgreSQL's uint64); macOS' dtrace rejects the latter.
+ * Also avoid "long long int", as SystemTap's dtrace(1) fails on that
+ * specific spelling.  PG type aliases below must be #define'd so that
+ * cpp expands them before dtrace sees the file.
  */
 #define LocalTransactionId unsigned int
 #define LWLockMode int
@@ -83,9 +86,9 @@ provider postgresql {
 	probe twophase__checkpoint__done();
 
 	probe smgr__md__read__start(ForkNumber, BlockNumber, Oid, Oid, Oid, int);
-	probe smgr__md__read__done(ForkNumber, BlockNumber, Oid, Oid, Oid, int, long long int, long long int);
+	probe smgr__md__read__done(ForkNumber, BlockNumber, Oid, Oid, Oid, int, ssize_t, size_t);
 	probe smgr__md__write__start(ForkNumber, BlockNumber, Oid, Oid, Oid, int);
-	probe smgr__md__write__done(ForkNumber, BlockNumber, Oid, Oid, Oid, int, long long int, long long int);
+	probe smgr__md__write__done(ForkNumber, BlockNumber, Oid, Oid, Oid, int, ssize_t, size_t);
 
 	probe wal__insert(unsigned char, unsigned char);
 	probe wal__switch();
-- 
2.53.0

Reply via email to