Potential memory leak in hlindex_open when open_table_from_share fails
@JoeJRW đang làm issue này rồi.
Từ ngày 18/5/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
In sql/vidx/vidx_index.cc, the hlindex_open function allocates memory for hlindex with my_malloc() at line 980, and increments s->hlindex->ref_count() at lines 988-990 before calling open_table_from_share().
However, when open_table_from_share() fails (error != 0), the function jumps to error_end at line 1001 without:
Decrementing the ref_count that was previously incremented
Freeing the allocated hlindex memory
Code location :
// Line 980: Allocate hlindex
hlindex = (TABLE *)my_malloc(key_memory_TABLE, sizeof(*hlindex), MYF(MY_WME));
// Lines 987-990: Increment ref_count
if (s->hlindex->tmp_table == NO_TMP_TABLE) {
mysql_mutex_lock(&LOCK_open);
s->hlindex->increment_ref_count();
mysql_mutex_unlock(&LOCK_open);
}
// Lines 993-997: Call open_table_from_share
int error = open_table_from_share(in_use, s->hlindex, hlindex_name,
(uint)(HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
HA_GET_INDEX | HA_TRY_READ_ONLY),
EXTRA_RECORD, in_use->open_options,
hlindex, false, hlindex_dd);
// Lines 999-1001: Problem: When error != 0, no cleanup before goto error_end
if (error != 0 || hlindex == nullptr) {
error_message = "Failed to open_table_from_share.";
goto error_end; // Memory leak here!
}
Note: open_table_from_share() does NOT free the passed outparam pointer on failure (verified in sql/table.cc). It only cleans internal resources.
Suggested fix:
if (error != 0 || hlindex == nullptr) {
error_message = "Failed to open_table_from_share.";
if (hlindex != nullptr) {
if (s->hlindex->tmp_table == NO_TMP_TABLE) {
mysql_mutex_lock(&LOCK_open);
s->hlindex->decrement_ref_count();
mysql_mutex_unlock(&LOCK_open);
}
my_free(hlindex);
hlindex = nullptr;
}
goto error_end;
}
- Ngôn ngữ chính
- C++
- Star
- 6k
- Fork
- 903
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc 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.
Issue khác của alibaba/AliSQL
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
-
Deployment Architecture IssuesCó thể làm lại được @p1p1bear đã nhận 70 ngày trước và không có pull request nào đang mở. Đang mở
Tất cả issue của alibaba/AliSQL
Issue tương tự
-
component: split-view platform: windows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
zen-browser/desktop#15616 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/ysql kind/bug priority/medium status/awaiting-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
yugabyte/yugabyte-db#34415 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
WayfireWM/wayfire#3148 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
backend:DirectX
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
llvm/llvm-project#227530 ·
Maintainer thường phản hồi trong vòng 1 ngày