Summary When running _testembed under LeakSanitizer, test_initconfig_get_api reports a memory leak.
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Bug report
Bug description:
Summary
When running _testembed under LeakSanitizer,
test_initconfig_get_api reports a memory leak.
Reproducer
Build CPython with sanitizers:
./configure \
--with-pydebug \
--with-address-sanitizer \
--with-undefined-behavior-sanitizer
make -j
Run the specific test:
ASAN_OPTIONS=detect_leaks=1 \
./Programs/_testembed test_initconfig_get_api
Observed result
LeakSanitizer reports:
ERROR: LeakSanitizer: detected memory leaks
Direct leak of 1 byte(s) in 1 object(s) allocated from:
#0 malloc
#1 PyInitConfig_GetStrList Python/initconfig.c:4024
#2 test_initconfig_get_api Programs/_testembed.c:1844
Root cause
In test_initconfig_get_api:
- The initial call to
PyInitConfig_GetStrList(config, "xoptions", &length, &items)
returns an empty list (length == 0).
- The returned items buffer was not freed.
- The PyInitConfig *config created by PyInitConfig_Create() was not released before returning.
Under LeakSanitizer, this results in a small direct leak and indirect leaks associated with the configuration lifetime.
Environment
-
Architecture: aarch64-linux-gnu
-
Built with: --with-address-sanitizer
-
Leak detected via: ASAN_OPTIONS=detect_leaks=1
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-145206
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu trong Programs/_testembed.c tại test_initconfig_get_api và xem xét kết quả PyInitConfig_GetStrList cùng thời gian tồn tại của cấu hình được mô tả trong báo cáo. Chạy bản build sanitizer được cung cấp và ./Programs/_testembed test_initconfig_get_api; hoàn tất nghĩa là bài kiểm thử kết thúc mà LeakSanitizer không báo cáo các rò rỉ cấu hình trực tiếp hoặc liên quan.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- c, python
- Lĩnh vực
- testing
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 25/100