Project

General

Profile

Actions

Bug #12259

closed

CTF shouldn't assume enum size

Added by John Levon over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

$ cat bad-ctf.c
#include <sys/types.h>

enum http_meth_t {
        HTTP_METH_OPTIONS,
        HTTP_METH_GET,
        HTTP_METH_HEAD,
        HTTP_METH_POST,
        HTTP_METH_PUT,
        HTTP_METH_DELETE,
        HTTP_METH_TRACE,
        HTTP_METH_CONNECT,
        HTTP_METH_OTHER, /* Must be the last entry */
} __attribute__((packed));

struct htx_sl {
        unsigned int flags; /* HTX_SL_F_* */
        union {
                struct {
                        enum http_meth_t meth;   /* method */
                } req;
                struct {
                        uint16_t         status; /* status code */
                } res;
        } info;
};

struct htx_sl sl;

$ gcc -g -c -o bad-ctf.o bad-ctf.c
f905ddb5-9113-c52a-d3ce-d0db83321d72:libctf $ ctfconvert bad-ctf.o
ctfconvert: failed to set type size for 4 to 0x1: Invalid argument

Distilled from haproxy


Related issues

Related to illumos gate - Bug #12898: ctf enum size detection should use DW_AT_byte_sizeClosedRobert Mustacchi

Actions
Actions #1

Updated by John Levon over 1 year ago

  • Subject changed from ctfconvert: failed to set type size for 4 to 0x1: Invalid argument to CTF shouldn't assume enum size

The issue is fairly prosaic: CTF is presuming all enums are ABI-sized, but a packed enum can in fact be of a different size.

Actions #2

Updated by John Levon over 1 year ago

Tested with full build and run of unit tests.

Actions #3

Updated by Electric Monk over 1 year ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit fe2dc8bddec347e173d402f53feeb492640a9f98

commit  fe2dc8bddec347e173d402f53feeb492640a9f98
Author: John Levon <john.levon@joyent.com>
Date:   2020-02-12T11:18:36.000Z

    12259 CTF shouldn't assume enum size
    Reviewed by: Robert Mustacchi <rm@fingolfin.org>
    Approved by: Dan McDonald <danmcd@joyent.com>

Actions #4

Updated by Robert Mustacchi 11 months ago

  • Related to Bug #12898: ctf enum size detection should use DW_AT_byte_size added
Actions

Also available in: Atom PDF