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

Aperta
#470 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
r
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
R
Stelle
227
Fork
86
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di r-lib/xml2

Tutte le issue di r-lib/xml2

Issue simili

Altre issue su R

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.