Setting function return_type clobbers other function type changes
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 52/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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".
- Lenguaje dominante
- C++
- Estrellas
- 1.3k
- Forks
- 304
- Merge medio
- 2 d 20 h
- PR fusionados (30 d)
- 10
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Vector35/binaryninja-api
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 84/100
Vector35/binaryninja-api#8715 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Vector35/binaryninja-api#8714 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
Vector35/binaryninja-api#8713 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
Vector35/binaryninja-api#8689 ·
Los mantenedores suelen responder en 2 días
-
Component: Python API
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Vector35/binaryninja-api#8649 ·
Los mantenedores suelen responder en 2 días
Todos los issues de Vector35/binaryninja-api
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
ESPresense/ESPresense#2680 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 Menos de una hora Aptitud para principiantes 75/100
stew675/llama-cpp-rdna-boosts#348 ·
Los mantenedores suelen responder en 1 día
-
Documentation: Add comprehensive newcomer onboarding guide, project structure, and local usage to READMEPosiblemente ocupada @Ash-Blanc la tomó hoy. Abiertoarea/other status/bot-triaged status/need-triage
Dificultad 2/5 Medio día Aptitud para principiantes 85/100
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día