Using Compile C Source on empty file opens edit segments dialog
Version and Platform (required):
- Binary Ninja Version: 5.1.7400-dev (does not happen on Stable)
- OS: macOS
- OS Version: 15.4
- CPU Architecture: M1
Bug Description: When trying to use Compile C Source on an empty file, I get an Add Memory Region popup with nothing filled. Given I don't know what assembly my source is about to produce, I cannot accurately fill out the dialog's fields. Pressing OK gives me an error and pressing Cancel closes the dialog and makes Compile C Source work?
Steps To Reproduce:
- New File
- Compile C Source
- Enter
void main() {}and select a platform - Press Compile
- See popup
Expected Behavior: I expected Compile C Source to put my code into the file and not open a dialog I cannot actually fill in.
Screenshots/Video Recording:
Jordan and I have seen this as well, will update this with more details later
Also -- I saw segments in the title and thought it was "segment fault" xD
The same behavior was observed when I add some new transformations and was first entering input into the transformations dialog. Seemed like it would have been unrelated to the transformations but I reverted my commit when it realized it so it's in the history for testing.
It's even easier to reproduce:
- Make a new empty file
- Start editing bytes
Every time you try to add a new hex byte you get the popup. It's due to:
https://github.com/Vector35/binaryninja/commit/577c01174473e8d6d6a1b218d7f388723fcb741d
Resolved in builds >= 5.1.7460
This isn't fixed. Repro steps
- Open a new mapped file
- Add a memory region
- Go to the end of that memory region
- try to assemble at that location
- Observe...
@emesare can you have a look at this? I saw your made the initial fix so you probably know what is going on. I have removed myself and assigned you
So there are two issues here:
- We were showing the add memory region dialog in "Raw" view, which is not intended behavior.
- We do not support writing OOB in mapped view, yes, the dialog for adding a memory region shows up, but the behavior before was simply to error out.
The first one is what this issue was about, and is what I fixed, the second one is an artifact of the "Add Memory Region" dialog being contextual and presenting itself in cases where one is unable to write.
We want to provide a better experience for users who are using a mapped view to write code and data, namely, we want to resize the underlying memory region to page sized boundaries automatically.
Attached below is the behavior on 5.0 stable, this is without the addition of the "Add Memory Region" dialog.
I believe the consensus like I mentioned about was to do some automatic extension of the region, but I don't know what exactly what that would look like and where it would be done, ideally it would be done with the permission of the user.
Some thoughts would be to populate the "Add Memory Region" dialog with the assembled bytes (instead of "Unitialized"), and populate the start and end for the user, however that does not mean the segment itself would be resized, so another option would need to be present for that, or the segment itself would need to adjust itself separately.
Initial support has landed for this. See https://github.com/Vector35/binaryninja-api/issues/5186#issuecomment-3066323965
Fixed in 5.1.7927-dev.