UB/crashes with libedit
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Bắt đầu từ readline_s_set_output() và clear_rl_outstream(), sau đó lần theo cách rl_initialize() lưu rl_outstream trong libedit. Tái hiện sự cố crash với libedit và musl libc, đồng thời điều tra đường dẫn rl_instream liên quan được đề cập trong báo cáo. Hoàn thành khi đầu ra của readline không còn truy cập vào một FILE* đã đóng và sự cố crash được báo cáo được ngăn chặn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
the code mentions compatibility with libedit, however the following happens in practice (e.g. while using irb from ruby 2.5.0):
- libedit initializes internal copy of rl_outstream
FILE*pointer during rl_initialize()
e = el_init_internal(rl_readline_name, rl_instream, rl_outstream, ...). this saves the current rl_outstream inel->el_outfile.
from that point on, libedit only operates on el_outfile in itsEditLine*context. - in this module, clear_rl_outstream() is called from readline_s_set_output() which fclose()s rl_outstream. then rl_outstream gets a fresh
FILE*assigned - however this does not affect libedit which continues using its el_outfile struct member. - next attempt to write anything to the output file via readline API causes a segfault - at least with musl libc, which is stricter in regards to UB.
probably this was never caught because the developers used glibc where the fclose() FILE structure happened to stay in RAM at the same address. or maybe the new FILE was allocated at the exact same address. it's 100% reproducible using libedit (latest release) and musl libc, and likely when using address sanitizer even on glibc.
it's likely that rl_instream handling has the same bug, but i only investigated the crash i actually got.
arguably it's a bug of libedit to supply rl_outstream but then use it only for initialization - but it appears nobody else was closing the FILE behind libedit's back so far, else it would be fixed in latest libedit version.
(background: i was about to update ruby from 2.5.0 to a newer version in my distro sabotage linux and noticed irb crashing, so i wanted to fix it before switching to a more modern version, so someone who needs to use the old version for whatever reason can go back in commit history and produce a 100% working version).
- Ngôn ngữ chính
- C
- Star
- 14
- Fork
- 7
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
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 ruby/readline-ext
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
ruby/readline-ext#20 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 35/100
ruby/readline-ext#17 ·
Tất cả issue của ruby/readline-ext
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
bradcypert/plum#53 ·
-
Component: GLib
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Status: Opened
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
nextbsd/nextbsd-userland#285 ·