[Bug] CWStringTest may not restore the original LC_CTYPE locale

Đang mở Phù hợp với người mới
#2,459 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c
Lĩnh vực
testing

Hướng nghiên cứu

Tìm CWStringTest::EresUnittest_AppendFormatInvalidLocale() trong mã kiểm thử GPORCA và xem cách mã lưu, khôi phục LC_CTYPE khi chuyển sang "C". Sao chép tên locale trước khi thay đổi, rồi khôi phục từ bản sao đó. Chạy bài kiểm thử bị ảnh hưởng trên Linux và xác nhận rằng nó khôi phục locale ban đầu cho các bài kiểm thử tiếp theo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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!
Ngôn ngữ chính
C
Star
1.5k
Fork
280
Merge trung bình
4 ngày 21 giờ
Pull request đã merge (30 ngày)
122

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/cloudberry

Tất cả issue của apache/cloudberry

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.