Skip to content

Surprising results with Change Type on field whose type is anonymous struct #7919

@comex

Description

@comex

Version and Platform (required):

  • Binary Ninja Version: 5.3.8955-dev (d60c8618)
  • Edition: Commercial
  • OS: macOS
  • OS Version: 26.3 Beta (25D5101c)
  • CPU Architecture: arm64

Bug Description:
When a struct contains a field whose type is an anonymous struct, Change Type doesn't work as expected on the field.

Steps To Reproduce:
Please provide all steps required to reproduce the behavior:

  1. File -> New Binary Data
  2. In the types view, right-click User Types and click "Create Types From C Source…". For the platform dialog I selected thumb2//thumb2 though it probably doesn't matter.
  3. Paste the following:
struct foo
{
    struct
    {
        int32_t x;
        int32_t y;
    } bar;
};
  1. Press Create.
  2. Now, if you right-click certain words and click "Change Type…", you get surprising results:
    a. Right-clicking the second word struct produces a "Set Member Type" dialog that apparently does nothing when accepted.
    b. Right-clicking bar produces an "Add Structure Field" dialog that adds fields to the anonymous struct.

Edit: c. Alternately, load some code that uses such a struct field, e.g. my_foo->bar.x = 5, then right-click bar and click "Change Type...". This produces a "Set Member Type" dialog with an invalid type for the field (clicking Accept produces "Error parsing specified type").

Expected Behavior:
For a., no particular expectations, but popping up a dialog that does nothing isn't right.
For b., I would like to be able to edit the type of bar similarly to pressing "Change Type…" on any other field name. (In the case where I ran into this, I wanted to change the type to an integer, and I couldn't edit the outer struct due to #7918.) I guess it is also useful to be able to add fields to the inner struct, but it should be possible to do both. Maybe selecting the closing brace should give you Add Structure Field while selecting the field name should give you Set Member Type.

Edit: For c., the behavior should be the same as b.

Admittedly, it would be odd for the usual single-line input field of Set Member Type dialogs to contain the whole anonymous struct definition, so ideally this calls for a unique dialog resembling the one that comes up when pressing "Change Type…" on the entire outer struct.

Metadata

Metadata

Assignees

Labels

State: Awaiting TriageIssue is waiting for more in-depth triage from a developer

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions