Bug 16066 - segfault of rawConnectionValue
Summary: segfault of rawConnectionValue
Status: ASSIGNED
Alias: None
Product: R
Classification: Unclassified
Component: I/O (show other bugs)
Version: R 3.1.2
Hardware: x86_64/x64/amd64 (64-bit) Linux
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2014-11-10 03:25 UTC by Wush Chi-Hsuan Wu
Modified: 2014-11-15 07:01 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wush Chi-Hsuan Wu 2014-11-10 03:25:45 UTC
Here is a minimal example:

> zz <- gzcon(con <- rawConnection(raw(0), "wb")) # start with empty raw vector
> writeBin(LETTERS, zz)
> rawConnectionValue(con)

 *** caught segfault ***
address 0x35336da, cause 'memory not mapped'

Traceback:
 1: rawConnectionValue(con)

Here is the sessionInfo():

> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
Comment 1 Martin Maechler 2014-11-11 08:52:35 UTC
Problem confirmed; seg.fault is (+-) reproducible. On one hand this is documented behavior: 

?gzcon     says (at end of 'Details'):

     The original connection becomes unusable: ...........

with that, you "should not" use 'con' anymore after   zz <- gzcon(con).

OTOH, I have been bitten by a similar version of the same problem before,
and I really think the "unusable" state should be an explicit property of con such that the connection functions can signal a decent error whenever the user tries to do something non-trivial with 'con'.   If that was in place,
summary.connection() could (and should) also reflect that, and print.connection() could show this property of "unusable".
{{Yes, I know this would make "unusable" into  "almost_unusable",
  but that is really what R should provide if possible}}
Comment 2 Wush Chi-Hsuan Wu 2014-11-15 07:01:03 UTC
(In reply to Martin Maechler from comment #1)
> Problem confirmed; seg.fault is (+-) reproducible. On one hand this is
> documented behavior: 
> 
> ?gzcon     says (at end of 'Details'):
> 
>      The original connection becomes unusable: ...........
> 
> with that, you "should not" use 'con' anymore after   zz <- gzcon(con).
> 
> OTOH, I have been bitten by a similar version of the same problem before,
> and I really think the "unusable" state should be an explicit property of
> con such that the connection functions can signal a decent error whenever
> the user tries to do something non-trivial with 'con'.   If that was in
> place,
> summary.connection() could (and should) also reflect that, and
> print.connection() could show this property of "unusable".
> {{Yes, I know this would make "unusable" into  "almost_unusable",
>   but that is really what R should provide if possible}}

Thanks for your reply. I did ignore the description about the original connection and thanks for your reminding.