[Bug] CWStringTest may not restore the original LC_CTYPE locale

Abierto Apto para principiantes
#2,459 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

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

Línea de trabajo

Busca CWStringTest::EresUnittest_AppendFormatInvalidLocale() en el código de pruebas de GPORCA e inspecciona cómo guarda y restaura LC_CTYPE alrededor del cambio a "C". Copia el nombre de la configuración regional antes de cambiarlo y luego restáuralo a partir de esa copia. Ejecuta la prueba afectada en Linux y confirma que restaura la configuración regional original para las pruebas posteriores.

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

Descripción

type: Bug
Apache Cloudberry version

main (the SETLOCALE call and saved pointer already exist in the PR base)

What happened

CWStringTest::EresUnittest_AppendFormatInvalidLocale() saves the pointer returned by SETLOCALE(LC_CTYPE, nullptr), switches the locale to "C", then passes the saved pointer back to restore the locale. In configurations where SETLOCALE maps to libc setlocale, that returned pointer refers to library-managed storage and may be overwritten by the next setlocale call. The restore can therefore leave LC_CTYPE set to "C" instead of restoring the prior locale, affecting later tests in the same process.

This code was present before PR 2453; the PR changes the standalone test to call setlocale directly but does not introduce the saved-pointer pattern.

What should happen instead

Copy the locale name before changing it, then restore using the copy.

How to reproduce

Run the equivalent sequence with a non-C LC_CTYPE locale (for example, LC_ALL=en_US.UTF-8): save setlocale(LC_CTYPE, nullptr), call setlocale(LC_CTYPE, "C"), then call setlocale(LC_CTYPE, saved). On this machine, the saved pointer's contents changed to "C" after the second call, and the restore left the current locale at "C".

The GPORCA test itself is excluded on Darwin; the test suite runs this case on Linux, where the same setlocale pointer lifetime should be verified.

Operating System

Reproduced with the platform libc on macOS 14.6, arm64. The affected GPORCA test is enabled on non-Darwin platforms.

Anything else
  • Yes, I am willing to submit a PR!
Lenguaje dominante
C
Estrellas
1.5k
Forks
280
Merge medio
4 d 21 h
PR fusionados (30 d)
122

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 apache/cloudberry

Todos los issues de apache/cloudberry

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.