Cranelift: interpreter: incorrect edge-case handling in fcvt_to_{u,s}int.i128

Abierto Apto para principiantes
#15,198 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@ryancbuckley ya está trabajando en esto.

Desde el 8/11/2026.

  • #15199 de @ryancbuckley — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
83/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust
Área
backend

Línea de trabajo

Lee cranelift/interpreter/src/step.rs alrededor de las conversiones de float a i128 y la documentación de instrucciones en cranelift/codegen/meta/src/shared/instructions.rs. Después, examina runtests/i128-conversion.clif y ejecuta la prueba pertinente del intérprete de Cranelift. El trabajo estará terminado cuando las conversiones con signo fuera del rango provoquen un trap y las conversiones sin signo devuelvan los valores esperados para entradas en [2¹²⁷, 2¹²⁸).

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug cranelift

Minor/pedantic bug. The float-to-int128 conversions in the interpreter misbehave when passed very large (or very negative) values:

  • fcvt_to_sint.i128 returns i128::MAX or i128::MIN for out-of-range inputs. The doc comments say it should trap.
  • fcvt_to_uint.i128 and fcvt_to_uint_sat.i128 clamp some large inputs (in the interval [2¹²⁷, 2¹²⁸)) to i128::MAX, even though those values should fit in the result.

I noticed this issue because runtests/i128-conversion.clif matches the implementation, so it has three incorrect expectations:

  • Line 14:
    • ; run: %fcvt_to_uint_i128(0x1.fffffep127) == 170141183460469231731687303715884105727
    • Should return: 340282346638528859811704183484516925440
  • The nearly identical call on line 40 should have the same result:
    • ; run: %fcvt_to_uint_sat_i128(0x1.fffffep127) == 170141183460469231731687303715884105727
  • Line 28:
    • ; run: %fcvt_to_sint_i128(0x1.fffffep127) == 170141183460469231731687303715884105727
    • Should trap

The root cause is that the interpreter's fcvt_to_uint and fcvt_to_sint cast the input with as i128 before the bounds check.

Lenguaje dominante
Rust
Estrellas
18.8k
Forks
1.9k
Merge medio
1 d 3 h
PR fusionados (30 d)
380

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de bytecodealliance/wasmtime

Todos los issues de bytecodealliance/wasmtime

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.