Setting function return_type clobbers other function type changes
Mantenedores costumam responder em até 2 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 52/100
Direção de pesquisa
The reproducer uses the Python API to show that setting return_type resets other function properties; it does not identify an implementation file or test path. Start by locating the return_type setter and the function type update logic it calls, then trace how property changes are preserved before analysis. Done means the reproducer no longer prints any “lost after setting” messages across its property combinations.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Version and Platform (required):
- Binary Ninja Version: 6.1.11009-dev
- Edition: Commercial
- OS: macOS
- OS Version: 27.0.1 (26A434)
- CPU Architecture: arm64
Bug Description:
In general you can make multiple changes before reanalyzing and BN will batch all of those changes. This applies even if you're changing multiple properties of the same object, and even if those properties are function properties which aren't stored separately but as part of the function type, such as is_pure, can_return, return_value, etc.
The one exception is return_type. If you set return_type, it resets all other aspects of the function type to what it was after the last analysis, clobbering any prior changes.
Steps To Reproduce:
This reproducer is somewhat long, but it tests every combination of function-type properties.
import binaryninja
from binaryninja import Type, types, variable
from binaryninja.types import *
from binaryninja.variable import *
platform = binaryninja.Platform["linux-x86_64"]
def location(register):
return ValueLocation.parse(register, platform.arch)
# Various function properties, along with values we can set them to (any
# arbitrary value except that it shouldn't match what we originally got from
# analysis).
PROPERTIES = [
("return_type", "int16_t"),
("return_value", ReturnValue(Type.char(), None)),
("return_value_location", location("rdx").with_confidence(255)),
("calling_convention", platform.arch.calling_conventions["win64"]),
("parameter_locations", ParameterLocations([location("rsi"), location("r8")])),
("has_variable_arguments", BoolWithConfidence(True)),
("can_return", BoolWithConfidence(False)),
("is_pure", BoolWithConfidence(False)),
("stack_adjustment", OffsetWithConfidence(8)),
("reg_stack_adjustments", {"x87": RegisterStackAdjustmentWithConfidence(1)}),
("clobbered_regs", RegisterSet(["rax", "rcx"])),
]
# In general we expect all of those properties to be able to vary
# independently. Changing one shouldn't affect any of the others.
# But there are exceptions:
EXPECTED_INTERFERENCE = [
# return_value consists of return_type + return_value_location.
{"return_value", "return_type"},
{"return_value", "return_value_location"},
# noreturn functions are forced to never clobber anything.
{"can_return", "clobbered_regs"},
]
for analyze_in_between in [True, False]:
print(f"for {analyze_in_between=}:")
for first, first_value in PROPERTIES:
for second, second_value in PROPERTIES:
if first == second:
continue
if {first, second} in EXPECTED_INTERFERENCE:
continue
# Create a new BV and function.
view = binaryninja.BinaryView.new(b"\xc3") # ret
view.platform = platform
function = view.create_user_function(0)
view.update_analysis_and_wait()
# Make sure we are actually changing something:
orig_value = getattr(function, first)
if str(orig_value) == str(first_value):
print(f" bug in test: {first} was already {first_value}")
# Set the first function property.
setattr(function, first, first_value)
# Maybe run a reanalysis.
if analyze_in_between:
view.update_analysis_and_wait()
# Set the second function property.
setattr(function, second, second_value)
view.update_analysis_and_wait()
read_back = getattr(function, first)
# Check if we got back the expected value.
if str(read_back) != str(first_value):
print(f" {first} lost after setting {second}: got {str(read_back)}, expected {str(first_value)}")
print("...done")
Expected Behavior:
The script should not print any "lost after setting" messages.
In reality, it prints one for every test where second is "return_type".
- Linguagem predominante
- C++
- Estrelas
- 1.3k
- Forks
- 304
- Merge médio
- 2d 20h
- PRs com merge (30d)
- 10
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de Vector35/binaryninja-api
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 84/100
Vector35/binaryninja-api#8715 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Vector35/binaryninja-api#8714 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
Vector35/binaryninja-api#8713 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 78/100
Vector35/binaryninja-api#8689 ·
Mantenedores costumam responder em até 2 dias
-
Component: Python API
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Vector35/binaryninja-api#8649 ·
Mantenedores costumam responder em até 2 dias
Todas as issues de Vector35/binaryninja-api
Issues semelhantes
-
Bug Core VIF
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 80/100
ESPresense/ESPresense#2680 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 Menos de uma hora Facilidade para iniciantes 75/100
stew675/llama-cpp-rdna-boosts#348 ·
Mantenedores costumam responder em até 1 dia
-
Documentation: Add comprehensive newcomer onboarding guide, project structure, and local usage to READMETalvez já em andamento @Ash-Blanc assumiu hoje. Abertaarea/other status/bot-triaged status/need-triage
Dificuldade 2/5 Meio dia Facilidade para iniciantes 85/100
-
bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia