binaryninja-api icon indicating copy to clipboard operation
binaryninja-api copied to clipboard

'create struct members referenced' breaks when structure size is greater than padding threshold (0x10000)

Open psifertex opened this issue 1 year ago • 3 comments

Structures over 0x400 aren't properly created when using "s" on the call of an allocator:

Note this is especially problematic because it's extremely difficult using the UI to turn the invalid __padding offset back into the actual padding.

(just press "s" on x0_7 and x0_6 in the attached)

Screenshot 2024-04-09 at 22 15 55

sample.zip

psifertex avatar Apr 10 '24 02:04 psifertex

The structure are created in the very same way. They look different in the types view because we did some UI hack to avoid the excessive padding in really large structs. You can test that if you create a structure >=0x400 directly, it is the same.

Does this behavior causes anything inconvenient?

xusheng6 avatar Apr 10 '24 06:04 xusheng6

This is just a consequence of the analysis.types.paddingThreshold setting being rather low by default. Any types >= that setting are rendered in a single line for performance reasons (previous users had trouble with structures that were gigabytes in size). The default setting value of 0x400 may be a bit too low for this, given that it can trigger with very reasonably sized structs as you've noticed here. So the crux of this issue is likely just "make that setting bigger by default," as it seems to otherwise be working as intended.

CouleeApps avatar Apr 10 '24 07:04 CouleeApps

Ultimately rendering it like that is actually fine visually if we fixed the fact that "create struct members referenced" feature fails to work when it's rendered like this. Don't know if that is an easy change or not though.

I might actually change the issue to reflect that is the real breaking bug.

psifertex avatar Apr 10 '24 14:04 psifertex