You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/09/23 09:52:02 UTC

[GitHub] [arrow] romainfrancois opened a new pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

romainfrancois opened a new pull request #8246:
URL: https://github.com/apache/arrow/pull/8246


   ``` r
   library(arrow, warn.conflicts = FALSE)
   
   a <- Array$create(1:10)
   tf <- tempfile()
   saveRDS(a, tf)
   
   b <- readRDS(tf)
   b$length()
   #> Error in Array__length(self): Invalid <Array>, external pointer to null
   ```
   
   <sup>Created on 2020-09-23 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0.9001)</sup>


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] nealrichardson commented on a change in pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
nealrichardson commented on a change in pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#discussion_r494391841



##########
File path: r/src/arrow_cpp11.h
##########
@@ -157,8 +157,15 @@ struct ns {
 
 template <typename Pointer>
 Pointer r6_to_pointer(SEXP self) {
-  return reinterpret_cast<Pointer>(
-      R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp)));
+  void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
+  if (p == nullptr) {

Review comment:
       Ah ok, I missed that that check translated some responses into `NULL`--though I don't think that's something we do widely, and maybe it would be better to make that more explicit in order to simplify the rest of the cases. 
   
   Regarding directly returning R6 objects from the cpp code, my thought had been more like the first idea of modifying `as_sexp` to map `T` to R6 classes. Our convention is that R6 class names are generally the bare C++ class name (assuming namespaces), i.e. `arrow::dataset::Dataset` is `Dataset` R6 class, with some exceptions. So we could record a map of those exceptions (e.g. "arrow::csv::TableReader" maps to "CsvTableReader") in cpp. If I were writing this in R, it could look something like this:
   
   ```r
   get_r6_constructor <- function(cpp_class) {
     if (cpp_class %in% names(special_cases)) {
       r6_name <- special_cases[[cpp_class]]
     } else {
       r6_name <- sub("^.*::(.*)$", "\\1", cpp_class)
     }
     get(r6_name, asNamespace("arrow"))$new
   }
   ```
   
   cc @bkietz 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] romainfrancois commented on a change in pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
romainfrancois commented on a change in pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#discussion_r494166354



##########
File path: r/src/arrow_cpp11.h
##########
@@ -157,8 +157,15 @@ struct ns {
 
 template <typename Pointer>
 Pointer r6_to_pointer(SEXP self) {
-  return reinterpret_cast<Pointer>(
-      R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp)));
+  void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
+  if (p == nullptr) {

Review comment:
       Another way would be to have the ability to directly create the R6 objects internally, either by having more code in 
   
   ```cpp
   template <typename T>
   SEXP as_sexp(const std::shared_ptr<T>& ptr) {
     return cpp11::external_pointer<std::shared_ptr<T>>(new std::shared_ptr<T>(ptr));
   }
   ```
   
   but we would need some sort of dispatch from `T` to the R6 object. 
   
   Or we would need to change the interface of many functions: 
   
   ```cpp
   // [[arrow::export]]
   std::shared_ptr<arrow::Array> StructArray__field(
       const std::shared_ptr<arrow::StructArray>& array, int i) {
     return array->field(i);
   }
   ```
   
   perhaps to: 
   
   ```cpp
   // [[arrow::export]]
   R6 StructArray__field(
       const std::shared_ptr<arrow::StructArray>& array, int i) {
     return R6(array->field(i), "Array");
   }
   ```
   
   but I don't think it's worth it




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] bkietz commented on a change in pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
bkietz commented on a change in pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#discussion_r494456605



##########
File path: r/src/arrow_cpp11.h
##########
@@ -157,8 +157,15 @@ struct ns {
 
 template <typename Pointer>
 Pointer r6_to_pointer(SEXP self) {
-  return reinterpret_cast<Pointer>(
-      R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp)));
+  void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
+  if (p == nullptr) {

Review comment:
       I'd prefer to specify a complete mapping T to R6 class names, rather than only listing special cases. This would be a pretty straightforward trait structure in c++




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] nealrichardson commented on pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
nealrichardson commented on pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#issuecomment-699156330


   @bkietz you can probably just push to it, or whatever you want. AFAICT that's the only outstanding issue and I'll merge when it is resolved (since it's earlier in the day here).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] bkietz commented on a change in pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
bkietz commented on a change in pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#discussion_r495490009



##########
File path: r/src/arrow_cpp11.h
##########
@@ -16,12 +16,15 @@
 // under the License.
 
 #include <cstring>  // for strlen
+#include <iostream>

Review comment:
       ```suggestion
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] nealrichardson commented on a change in pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
nealrichardson commented on a change in pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#discussion_r494391841



##########
File path: r/src/arrow_cpp11.h
##########
@@ -157,8 +157,15 @@ struct ns {
 
 template <typename Pointer>
 Pointer r6_to_pointer(SEXP self) {
-  return reinterpret_cast<Pointer>(
-      R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp)));
+  void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
+  if (p == nullptr) {

Review comment:
       Ah ok, I missed that that check translated some responses into `NULL`--though I don't think that's something we do widely, and maybe it would be better to make that more explicit in order to simplify the rest of the cases. 
   
   Regarding directly returning R6 objects from the cpp code, my thought had been more like the first idea of modifying `as_sexp` to map `T` to R6 classes. Our convention is that R6 class names are generally the bare C++ class name (assuming namespaces), i.e. `arrow::dataset::Dataset` is `Dataset` R6 class, with some exceptions. So we could record a map of those exceptions (e.g. "arrow::csv::TableReader" maps to "CsvTableReader") in cpp. If I were writing this in R, it could look something like this:
   
   ```r
   get_r6_constructor <- function(cpp_class) {
     if (cpp_class %in% names(special_cases)) {
       r6_name <- special_cases[[cpp_class]]
     } else {
       r6_name <- sub("^.*::(.*)$", "\\1", cpp_class)
     }
     get(r6_name, asNamespace("arrow"))$new
   }
   ```
   
   cc @bkietz 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] romainfrancois commented on pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
romainfrancois commented on pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#issuecomment-698219857


   Is there something I can use to demangle the type name ? 
   
   ``` r
   arrow:::Array__length(1)
   #> Error in arrow:::Array__length(1): Invalid R object for NSt3__110shared_ptrIN5arrow5ArrayEEE, must be an ArrowObject
   ```
   
   <sup>Created on 2020-09-24 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0.9001)</sup>
   
   Rcpp had `DEMANGLE` https://github.com/RcppCore/Rcpp/blob/85f6b275966cdfb1dfd32575e2da509ea2642084/src/api.cpp#L111
   
   @bkietz ? 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] bkietz closed pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
bkietz closed pull request #8246:
URL: https://github.com/apache/arrow/pull/8246


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] romainfrancois commented on a change in pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
romainfrancois commented on a change in pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#discussion_r494093172



##########
File path: r/tests/testthat/test-arrow.R
##########
@@ -47,3 +47,12 @@ r_only({
     )
   })
 })
+
+test_that("arrow gracefully fails to load objects from other sessions (ARROW-10071)", {
+  a <- Array$create(1:10)
+  tf <- tempfile(); on.exit(unlink(tf))
+  saveRDS(a, tf)
+
+  b <- readRDS(tf)

Review comment:
       serialization of external pointer loses the pointer

##########
File path: r/src/arrow_cpp11.h
##########
@@ -157,8 +157,15 @@ struct ns {
 
 template <typename Pointer>
 Pointer r6_to_pointer(SEXP self) {
-  return reinterpret_cast<Pointer>(
-      R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp)));
+  void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
+  if (p == nullptr) {
+    SEXP klass = Rf_getAttrib(self, R_ClassSymbol);
+    std::string first_class(Rf_isNull(klass) ? "ArrowObject"
+                                             : CHAR(STRING_ELT(klass, 0)));

Review comment:
       I'll refine about the NULL case, but the class we do want is the first one: 
   
   ``` r
   library(arrow, warn.conflicts = FALSE)
   
   a <- Array$create(1:10)
   class(a)
   #> [1] "Array"       "ArrowObject" "R6"
   ```
   
   <sup>Created on 2020-09-24 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0.9001)</sup>

##########
File path: r/src/arrow_cpp11.h
##########
@@ -157,8 +157,15 @@ struct ns {
 
 template <typename Pointer>
 Pointer r6_to_pointer(SEXP self) {
-  return reinterpret_cast<Pointer>(
-      R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp)));
+  void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
+  if (p == nullptr) {

Review comment:
       We can't really do that because of the implicit `else NULL` case: 
   
   ```r
   shared_ptr <- function(class, xp) {
     if (!shared_ptr_is_null(xp)) class$new(xp)
   }
   ```
   
   There are cases where we want an R NULL when the internal C++ shared pointer holds a C++ null pointer, e.g. when we call: 
   
   ```c++
   std::shared_ptr<Array> RecordBatch::GetColumnByName(const std::string& name) const {
     auto i = schema_->GetFieldIndex(name);
     return i == -1 ? NULLPTR : column(i);
   }
   ```
   
   For example in this tests: 
   
   ```r
   test_that("[[ and $ on RecordBatch", {
     [...]
     expect_null(batch$qwerty)
     [...]
   })
   ```
   
   having the extra layer with the R function `shared_ptr(T, .)` maybe calling `T$new(.)` gives the NULL. 

##########
File path: r/src/arrow_cpp11.h
##########
@@ -157,8 +157,15 @@ struct ns {
 
 template <typename Pointer>
 Pointer r6_to_pointer(SEXP self) {
-  return reinterpret_cast<Pointer>(
-      R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp)));
+  void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
+  if (p == nullptr) {

Review comment:
       Another way would be to have the ability to directly create the R6 objects internally, either by having more code in 
   
   ```cpp
   template <typename T>
   SEXP as_sexp(const std::shared_ptr<T>& ptr) {
     return cpp11::external_pointer<std::shared_ptr<T>>(new std::shared_ptr<T>(ptr));
   }
   ```
   
   but we would need some sort of dispatch from `T` to the R6 object. 
   
   Or we would need to change the interface of many functions: 
   
   ```cpp
   // [[arrow::export]]
   std::shared_ptr<arrow::Array> StructArray__field(
       const std::shared_ptr<arrow::StructArray>& array, int i) {
     return array->field(i);
   }
   ```
   
   perhaps to: 
   
   ```cpp
   // [[arrow::export]]
   R6 StructArray__field(
       const std::shared_ptr<arrow::StructArray>& array, int i) {
     return R6(array->field(i), "Array");
   }
   ```
   
   but I don't think it's worth it




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] bkietz commented on a change in pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
bkietz commented on a change in pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#discussion_r494456605



##########
File path: r/src/arrow_cpp11.h
##########
@@ -157,8 +157,15 @@ struct ns {
 
 template <typename Pointer>
 Pointer r6_to_pointer(SEXP self) {
-  return reinterpret_cast<Pointer>(
-      R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp)));
+  void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
+  if (p == nullptr) {

Review comment:
       I'd prefer to specify a complete mapping T to R6 class names, rather than only listing special cases. This would be a pretty straightforward trait structure in c++




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] romainfrancois commented on a change in pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
romainfrancois commented on a change in pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#discussion_r494093172



##########
File path: r/tests/testthat/test-arrow.R
##########
@@ -47,3 +47,12 @@ r_only({
     )
   })
 })
+
+test_that("arrow gracefully fails to load objects from other sessions (ARROW-10071)", {
+  a <- Array$create(1:10)
+  tf <- tempfile(); on.exit(unlink(tf))
+  saveRDS(a, tf)
+
+  b <- readRDS(tf)

Review comment:
       serialization of external pointer loses the pointer




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] nealrichardson commented on a change in pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
nealrichardson commented on a change in pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#discussion_r493663218



##########
File path: r/src/arrow_cpp11.h
##########
@@ -157,8 +157,15 @@ struct ns {
 
 template <typename Pointer>
 Pointer r6_to_pointer(SEXP self) {
-  return reinterpret_cast<Pointer>(
-      R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp)));
+  void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
+  if (p == nullptr) {

Review comment:
       If we're checking for nullptr here, can we remove the `shared_ptr_is_null` check inside the `shared_ptr()` constructor? Then we can just `$new()` to create the R6 objects.

##########
File path: r/tests/testthat/test-arrow.R
##########
@@ -47,3 +47,12 @@ r_only({
     )
   })
 })
+
+test_that("arrow gracefully fails to load objects from other sessions (ARROW-10071)", {
+  a <- Array$create(1:10)
+  tf <- tempfile(); on.exit(unlink(tf))
+  saveRDS(a, tf)
+
+  b <- readRDS(tf)

Review comment:
       I don't understand why this fails--`a` still exists so I'd expect that a pointer to it would still work, even if it had been written to a file--but I trust you that it does :)

##########
File path: r/src/arrow_cpp11.h
##########
@@ -157,8 +157,15 @@ struct ns {
 
 template <typename Pointer>
 Pointer r6_to_pointer(SEXP self) {
-  return reinterpret_cast<Pointer>(
-      R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp)));
+  void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
+  if (p == nullptr) {
+    SEXP klass = Rf_getAttrib(self, R_ClassSymbol);
+    std::string first_class(Rf_isNull(klass) ? "ArrowObject"
+                                             : CHAR(STRING_ELT(klass, 0)));

Review comment:
       1) if this is an R6 object, how can class ever be NULL?
   
   2) Why not take the last element in `klass`, i.e. the actual subclass?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] romainfrancois commented on a change in pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
romainfrancois commented on a change in pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#discussion_r494095853



##########
File path: r/src/arrow_cpp11.h
##########
@@ -157,8 +157,15 @@ struct ns {
 
 template <typename Pointer>
 Pointer r6_to_pointer(SEXP self) {
-  return reinterpret_cast<Pointer>(
-      R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp)));
+  void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
+  if (p == nullptr) {
+    SEXP klass = Rf_getAttrib(self, R_ClassSymbol);
+    std::string first_class(Rf_isNull(klass) ? "ArrowObject"
+                                             : CHAR(STRING_ELT(klass, 0)));

Review comment:
       I'll refine about the NULL case, but the class we do want is the first one: 
   
   ``` r
   library(arrow, warn.conflicts = FALSE)
   
   a <- Array$create(1:10)
   class(a)
   #> [1] "Array"       "ArrowObject" "R6"
   ```
   
   <sup>Created on 2020-09-24 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0.9001)</sup>




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#issuecomment-697259565


   https://issues.apache.org/jira/browse/ARROW-10071


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] bkietz commented on pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
bkietz commented on pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#issuecomment-699153455


   @romainfrancois yes, should I make a PR to your branch?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] romainfrancois commented on a change in pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
romainfrancois commented on a change in pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#discussion_r494154401



##########
File path: r/src/arrow_cpp11.h
##########
@@ -157,8 +157,15 @@ struct ns {
 
 template <typename Pointer>
 Pointer r6_to_pointer(SEXP self) {
-  return reinterpret_cast<Pointer>(
-      R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp)));
+  void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
+  if (p == nullptr) {

Review comment:
       We can't really do that because of the implicit `else NULL` case: 
   
   ```r
   shared_ptr <- function(class, xp) {
     if (!shared_ptr_is_null(xp)) class$new(xp)
   }
   ```
   
   There are cases where we want an R NULL when the internal C++ shared pointer holds a C++ null pointer, e.g. when we call: 
   
   ```c++
   std::shared_ptr<Array> RecordBatch::GetColumnByName(const std::string& name) const {
     auto i = schema_->GetFieldIndex(name);
     return i == -1 ? NULLPTR : column(i);
   }
   ```
   
   For example in this tests: 
   
   ```r
   test_that("[[ and $ on RecordBatch", {
     [...]
     expect_null(batch$qwerty)
     [...]
   })
   ```
   
   having the extra layer with the R function `shared_ptr(T, .)` maybe calling `T$new(.)` gives the NULL. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] romainfrancois commented on pull request #8246: ARROW-10071: [R] segfault with ArrowObject from previous session, or saved

Posted by GitBox <gi...@apache.org>.
romainfrancois commented on pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#issuecomment-698219857


   Is there something I can use to demangle the type name ? 
   
   ``` r
   arrow:::Array__length(1)
   #> Error in arrow:::Array__length(1): Invalid R object for NSt3__110shared_ptrIN5arrow5ArrayEEE, must be an ArrowObject
   ```
   
   <sup>Created on 2020-09-24 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0.9001)</sup>
   
   Rcpp had `DEMANGLE` https://github.com/RcppCore/Rcpp/blob/85f6b275966cdfb1dfd32575e2da509ea2642084/src/api.cpp#L111
   
   @bkietz ? 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org