`read_xml` crashes R when trying to read from an `archive::archive_read` connection if the connection is closed beforehand

Đang mở
#470 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
r
Lĩnh vực
backend

Hướng nghiên cứu

Run the supplied R reproducer using rawConnection, archive::archive_read, close(), and xml2::read_xml(). Trace whether the failure belongs to xml2::read_xml or archive::archive_read when the underlying connection is closed, and define behavior that avoids an R crash for this case.

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

Mô tả

I've been handed a database in which one of the fields contains XML documents as compressed blobs (ZIP/PK archives). Rather than writing the file out to disk every time and reading it in using read_xml I tried using the archive package's bindings to libarchive to read it directly. It works great except that I'm trying to close the connections properly afterward and learned that R crashes if I incorrectly close the rawConnection object before calling read_xml.

xml_text <- '<text>Hi</text>'
blob <- charToRaw(xml_text)

blob_con <- rawConnection(blob)
spec_con <- archive::archive_read(blob_con)
close(blob_con)
xml2::read_xml(spec_con)

The error I get when R crashes is:

Error in (function (con, rw = "")  : invalid connection
terminate called after throwing an instance of 'cpp11::unwind_exception'
  what():  std::exception

I honestly don't know whether this is an archive problem or an xml2 problem so happy to repost there, I just don't know enough about the internals to learn where the problem itself is and read_xml is what's currently causing the crash when called.

I'm on R 4.5.1 with xml2 1.3.8 and archive version 1.1.12.

Ngôn ngữ chính
R
Star
227
Fork
86
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

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 r-lib/xml2

Tất cả issue của r-lib/xml2

Issue tương tự

Thêm issue về R

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.