Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization of s2 geography data results in a segfault #259

Open
tzakharko opened this issue Jul 12, 2024 · 0 comments
Open

Serialization of s2 geography data results in a segfault #259

tzakharko opened this issue Jul 12, 2024 · 0 comments

Comments

@tzakharko
Copy link

I am unable to work with serialized s2 data since it crashes R for me (tested on Apple Silicon, R version 4.4.1). Note: s2_points work correctly.

Reprex:

p <- s2::s2_geog_point(0, 0)
data <- serialize(p, NULL)
unserialize(data)

Output:

 *** caught segfault ***
address 0x0, cause 'invalid permissions'

Traceback:
 1: wk_handle.s2_geography(handleable, wkt_format_handler(precision = precision,     trim = trim, max_coords = max_coords), ...)
 2: wk_handle(handleable, wkt_format_handler(precision = precision,     trim = trim, max_coords = max_coords), ...)
 3: wk::wk_format(x, precision = precision, max_coords = max_coords,     trim = trim)
 4: format.s2_geography(utils::head(x, max_print))
 5: format(utils::head(x, max_print))
 6: print.wk_vctr(x)
 7: (function (x, ...) UseMethod("print"))(x)
An irrecoverable exception occurred. R is aborting now ...

More information

It appears that the external pointer data is not being restored correctly — note how the inner extptr is set to 0x0 for the unserialized data.

p <- s2::s2_geog_point(0, 0)

.Internal(inspect(p))
#> @12b1c80a0 19 VECSXP g0c1 [OBJ,REF(3),ATT] (len=1, tl=0)
#>   @12b1dac08 22 EXTPTRSXP g0c0 [REF(2)] <0x129f040a0>
#> ATTRIB:
#>   @12b1df0a8 02 LISTSXP g0c0 [REF(1)] 
#>     TAG: @15a0111d0 01 SYMSXP g1c0 [MARK,REF(33769),LCK,gp=0x6000] "class" (has value)
#>     @14a2c06c8 16 STRSXP g0c2 [REF(1)] (len=2, tl=0)
#>       @13bb1a348 09 CHARSXP g1c2 [MARK,REF(130),gp=0x61,ATT] [ASCII] [cached] "s2_geography"
#>       @13ad07ce8 09 CHARSXP g0c1 [REF(79),gp=0x60,ATT] [ASCII] [cached] "wk_vctr"
data <- serialize(p, NULL)

p <- unserialize(data)
.Internal(inspect(p))
#> @12b2da4e8 19 VECSXP g0c1 [OBJ,REF(2),ATT] (len=1, tl=0)
#>   @12b2e6670 22 EXTPTRSXP g0c0 [REF(2)] <0x0>
#> ATTRIB:
#>   @12b2e6638 02 LISTSXP g0c0 [REF(1)] 
#>     TAG: @15a0111d0 01 SYMSXP g1c0 [MARK,REF(33812),LCK,gp=0x6000] "class" (has value)
#>     @15aebac88 16 STRSXP g0c2 [REF(1)] (len=2, tl=0)
#>       @13bb1a348 09 CHARSXP g1c2 [MARK,REF(131),gp=0x61,ATT] [ASCII] [cached] "s2_geography"
#>       @13ad07ce8 09 CHARSXP g0c1 [REF(80),gp=0x60,ATT] [ASCII] [cached] "wk_vctr"

Created on 2024-07-12 with reprex v2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant