[Bug] CWStringTest may not restore the original LC_CTYPE locale

Aberta Para iniciantes
#2,459 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
78/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
c
Domínio
testing

Direção de pesquisa

Encontre CWStringTest::EresUnittest_AppendFormatInvalidLocale() no código de testes do GPORCA e inspecione como ele salva e restaura LC_CTYPE ao alternar para "C". Copie o nome da localidade antes de alterá-lo e depois restaure-o a partir dessa cópia. Execute o teste afetado no Linux e confirme que ele restaura a localidade original para os testes seguintes.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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!
Linguagem predominante
C
Estrelas
1.5k
Forks
280
Merge médio
5d 35min
PRs com merge (30d)
128

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de apache/cloudberry

Todas as issues de apache/cloudberry

Issues semelhantes

Mais issues de C

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.