[DTrace-devel] [PATCH] Fix type alignment handling for enums

Kris Van Hees kris.van.hees at oracle.com
Fri Aug 20 11:10:03 PDT 2021


On Fri, Aug 20, 2021 at 01:55:56PM -0400, Eugene Loh wrote:
> Sorry, I'm clueless here.  What is the issue?  Is there a user-visible 
> bug?  Specifically, should this change be accompanied by a test?  I 
> simply do not understand the issue at stake here.

The issue has a test already in that a DTrace built against libctf with the
latest revisions will cause a test failure for tst.SizeofDataTypes.d.  I'll
add that to the commit message.
> 
> On 8/20/21 2:47 AM, Kris Van Hees wrote:
> > The type alignment handling code used to determine the alignment size
> > for a given datatype was treating enums as if they were integers, but
> > that is incorrect.  It should (just like integers and pointers) have
> > its alignment set to match its size, but it should avoid the explicit
> > void-checking that is done for integers.
> >
> > Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> > ---
> >   libdtrace/dt_parser.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libdtrace/dt_parser.c b/libdtrace/dt_parser.c
> > index e9dcff98..bac895a2 100644
> > --- a/libdtrace/dt_parser.c
> > +++ b/libdtrace/dt_parser.c
> > @@ -1630,7 +1630,6 @@ dt_node_decl(void)
> >   			size = ctf_type_size(dtt.dtt_ctfp, dtt.dtt_type);
> >   
> >   			switch (kind) {
> > -			case CTF_K_ENUM:
> >   			case CTF_K_INTEGER:
> >   				if (ctf_type_encoding(dtt.dtt_ctfp, type,
> >   						      &cte) == 0 &&
> > @@ -1639,6 +1638,7 @@ dt_node_decl(void)
> >   						"cannot have void object: %s\n",
> >   						dsp->ds_ident);
> >   				/*FALLTHRU*/
> > +			case CTF_K_ENUM:
> >   			case CTF_K_POINTER:
> >   				alignment = size;
> >   				break;
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list