Skip to content

Commit

Permalink
test: add a test for libctf bug 30264
Browse files Browse the repository at this point in the history
If present, this bug breaks offsetof (and anything else requiring
reliable offset info, like, oh, say, *any access*) to fields of
unnamed structs/unions at nonzero offsets within their containing
struct/union.

(We just check offsetof, because it's simpler than doing full access
checks.  We check only the in-kernel CTF, because the D language does
not support unnamed struct/union fields at all.)

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
nickalcock authored and kvanhees committed May 24, 2023
1 parent c4d1c1a commit 0b7a061
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/unittest/types/tst.nested-unnamed-structs.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/

/*
* ASSERTION:
* Check for the absence of a libctf bug breaking offsets of
* members of nested unnamed structs in the kernel.
* See https://sourceware.org/bugzilla/show_bug.cgi?id=30264
*
*/

#pragma D option quiet

BEGIN {
printf("offset is %i\n", offsetof(struct rds`rds_message, atomic));
}

BEGIN
/ offsetof(struct rds`rds_message, atomic) == 0 /
{
exit(1);
}

BEGIN
/ offsetof(struct rds`rds_message, atomic) != 0 /
{
exit(0);
}
7 changes: 7 additions & 0 deletions test/unittest/types/tst.nested-unnamed-structs.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

if ! $(grep -q '^rds ' /proc/modules); then
exit 1
fi

exit 0

0 comments on commit 0b7a061

Please sign in to comment.