buffer.toString() fails when buffer.length >= 32 and null-terminated on big-endian
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 122k
- Forks
- 37.3k
- Merge medio
- 4 d 2 h
- PR fusionados (30 d)
- 283
Descripción
Version
v24.18.0, v26.5.0
Platform
Linux zelenka 6.12.96+deb13-s390x #1 SMP Debian 6.12.96-1 (2026-07-20) s390x GNU/Linux
Subsystem
StringBytes
What steps will reproduce the bug?
Run these commands
node -p 'const b=Buffer.alloc(32); b.write("\u3000",0,"utf8");b.toString().charCodeAt(0);'
node -p 'Buffer.from("\u3000").toString().charCodeAt(0);'
How often does it reproduce? Is there a required condition?
Always reproduced on big-endian.
What is the expected behavior? Why is that the expected behavior?
both commands should return 12288
What do you see instead?
On big-endian architecture (e.g. s390x) the first call returns 0 and the last 12288.
Additional information
Tested with the executables provided by nodejs.org.
v22.23.1 is not affected.
Also, this gives the correct result on big-endian:
node -p 'const b=Buffer.alloc(31); b.write("\u3000",0,"utf8");b.toString().charCodeAt(0);'
So the suspected commits are the ones adding the special cases for buflen >= 32 here:
https://github.com/nodejs/node/blob/68130800586634f17812f3b0837d869a36725e98/src/string_bytes.cc#L751
and here
https://github.com/nodejs/node/blob/68130800586634f17812f3b0837d869a36725e98/src/string_bytes.cc#L625
Guía de contribución
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.
Línea de trabajo
Ejecuta los dos comandos de reproducción en un sistema big-endian y compáralos con el caso de 31 bytes. Después, inspecciona src/string_bytes.cc alrededor de las líneas referenciadas 625 y 751, centrándote en el tratamiento especial de buflen >= 32. Se considera terminado cuando ambos comandos devuelvan 12288 en big-endian sin cambiar el comportamiento existente para 31 bytes.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- cpp, nodejs
- Área
- backend, operating-systems
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Tranquilo
- Claridad
- Bien especificado
- Aptitud para principiantes
- 68/100