You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "sly1061101 (via GitHub)" <gi...@apache.org> on 2023/05/06 10:43:16 UTC

[GitHub] [arrow] sly1061101 opened a new issue, #35465: "NumericArray" is not exported and causes issue on Android

sly1061101 opened a new issue, #35465:
URL: https://github.com/apache/arrow/issues/35465

   ### Describe the bug, including details regarding any error messages, version, and platform.
   
   Currently, the `ARROW_EXPORT` attribute is not added for class `NumericArray`, and it causes issue on Android. 
   
   If an application is linked with `libarrow.so`, a `NumericArray` object created inside `libarrow.so` seems to be considered as a different type than `NumericArray` used in the application. Therefore, operations like `dynamic_cast` or `dynamic_pointer_cast` will fail.
   
   Here is a specific example:
   
   ```
   #include <cstdio>
   
   #include "arrow/array/array_primitive.h"
   #include "arrow/array/util.h"
   
   int main()
   {
       auto array = *MakeArrayOfNull(arrow::uint64(), 100);
       auto uint64_array = std::dynamic_pointer_cast<arrow::UInt64Array>(array);
       if (uint64_array)
       {
           printf("dynamic_cast is successful\n");
       }
       else
       {
           printf("dynamic_cast failed\n");
       }
   	return 0;
   }
   ```
   
   Note that `MakeArrayOfNull(arrow::uint64(), 100)` causes arrow library to generate a `NumericArray<UInt64Type>` (aka `UInt64Array`) object, and coverts it to its base class pointer `Array`, then return it. Then the app tries to cast it back to `UInt64Array`, but on Android, the operation fails, i.e. the output is `dynamic_cast failed`.
   
   This is only observed on Android. It doesn't happen on Linux. Initially I thought it's because of compiler difference, as Android uses Clang. But I then observed that even if I use Clang to build both arrow and the sample app on Linux, the issue won't reproduce. So it might be related to the dynamic linker implementation difference on Android and Linux.
   
   I also noticed that if `ARROW_EXPORT` is added for `class NumericArray` declaration in `arrow/cpp/src/arrow/type_fwd.h`, then the issue goes away. However, it doesn't work if we the export at class defination in `arrow/cpp/src/arrow/array/array_primitive.h`, maybe because it's a template class and the declaration of instantiations like `UInt64Array` is in `arrow/cpp/src/arrow/type_fwd.h`.
   
   ### Component(s)
   
   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.

To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org.apache.org

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


[GitHub] [arrow] ianmcook commented on issue #35465: "NumericArray" and its instantiations are not exported and causes issue on Android when `-fvisibility=hidden` is used

Posted by "ianmcook (via GitHub)" <gi...@apache.org>.
ianmcook commented on issue #35465:
URL: https://github.com/apache/arrow/issues/35465#issuecomment-1540716199

   @sly1061101 thanks for the bug report. I'm not sure if anyone in the core group of Arrow maintainers has an Android development environment set up to reproduce and troubleshoot this. Any chance you'd be interested to open a pull request to take a stab at resolving 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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow] kou commented on issue #35465: "NumericArray" and its instantiations are not exported and causes issue on Android when `-fvisibility=hidden` is used

Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on issue #35465:
URL: https://github.com/apache/arrow/issues/35465#issuecomment-1541055012

   Why do you want to specify `-fvisibility=hidden`?
   If you want to specify it explicitly, how about building with `g++ ... -DARROW_EXPORT='[[gnu::visibility("extern")]]'`?


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow] sly1061101 commented on issue #35465: "NumericArray" is not exported and causes issue on Android

Posted by "sly1061101 (via GitHub)" <gi...@apache.org>.
sly1061101 commented on issue #35465:
URL: https://github.com/apache/arrow/issues/35465#issuecomment-1537657705

   Note that `-fvisibility=hidden` needs to be set for the issue to reproduce


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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