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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]