[ 
https://issues.apache.org/jira/browse/ARROW-2189?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16421857#comment-16421857
 ] 

Kouhei Sutou commented on ARROW-2189:
-------------------------------------

Thanks. I confirmed it.

I also confirmed the followings:

  * Apache Arrow C++ compiled with g++-4.8 + -DCMAKE_BUILD_TYPE=Debug and 
foo.cpp compiled with g++-4.9 work well

  * Apache Arrow C++ compiled with g++-4.8 + -DCMAKE_BUILD_TYPE=Release and 
foo.cpp compiled with g++-4.9 don't work (crashed)

 Backtrace:

{noformat}
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt full
#0  0x0000000000000000 in ?? ()
No symbol table info available.
#1  0x00007ffff7941490 in arrow::ArrayBuilder::Init (
    this=this@entry=0x7fffffffe640, capacity=capacity@entry=32)
    at /arrow/cpp/src/arrow/builder.cc:67
        _s = {state_ = 0x20}
        to_alloc = 4
        byte_capacity = <optimized out>
#2  0x00007ffff79584e0 in arrow::PrimitiveBuilder<arrow::Int64Type>::Init (
    this=0x7fffffffe640, capacity=32) at /arrow/cpp/src/arrow/builder.cc:233
        _s = {state_ = 0x20}
        nbytes = <optimized out>
#3  0x00007ffff7948b58 in arrow::PrimitiveBuilder<arrow::Int64Type>::Resize (
    this=0x7fffffffe640, capacity=32) at /arrow/cpp/src/arrow/builder.cc:253
        _s = {state_ = 0x1}
#4  0x00007ffff793e7ab in arrow::ArrayBuilder::Reserve (
    this=this@entry=0x7fffffffe640, elements=elements@entry=1)
    at /arrow/cpp/src/arrow/builder.cc:113
No locals.
#5  0x000000000040168f in Append (val=1, this=0x7fffffffe640)
    at /tmp/local-4.8/include/arrow/builder.h:276
        _s = {state_ = 0x616848}
#6  main () at foo.cpp:10
        pool = 
    0x7ffff7dd91a0 <arrow::default_memory_pool()::default_memory_pool_>
        builder = {<arrow::PrimitiveBuilder<arrow::Int64Type>> = 
{<arrow::ArrayBuilder> = {
              _vptr.ArrayBuilder = 0x4024f0 <vtable for 
arrow::NumericBuilder<arrow::Int64Type>+16>, type_ = std::shared_ptr (count 2, 
weak 0) 0x616848, 
              pool_ = 0x7ffff7dd91a0 
<arrow::default_memory_pool()::default_memory_pool_>, null_bitmap_ = 
std::shared_ptr (count 1, weak 0) 0x616890, 
              null_count_ = 0, null_bitmap_data_ = 0x0, length_ = 0, 
              capacity_ = 0, children_ = std::vector of length 0, capacity 0}, 
            data_ = std::shared_ptr (empty) 0x0, 
            raw_data_ = 0x0}, <No data fields>}
        buffer = <optimized out>
(gdb) f 1
#1  0x00007ffff7941490 in arrow::ArrayBuilder::Init (
    this=this@entry=0x7fffffffe640, capacity=capacity@entry=32)
    at /arrow/cpp/src/arrow/builder.cc:67
67        RETURN_NOT_OK(null_bitmap_->Resize(to_alloc));
(gdb) list
62      }
63      
64      Status ArrayBuilder::Init(int64_t capacity) {
65        int64_t to_alloc = BitUtil::CeilByte(capacity) / 8;
66        null_bitmap_ = std::make_shared<PoolBuffer>(pool_);
67        RETURN_NOT_OK(null_bitmap_->Resize(to_alloc));
68        // Buffers might allocate more then necessary to satisfy padding 
requirements
69        const int64_t byte_capacity = null_bitmap_->capacity();
70        capacity_ = capacity;
71        null_bitmap_data_ = null_bitmap_->mutable_data();
(gdb) p to_alloc
$3 = 4
{noformat}

 I don't know why...

BTW, why do you want to use g++-4.9?

> [C++] Seg. fault on make_shared<PoolBuffer>
> -------------------------------------------
>
>                 Key: ARROW-2189
>                 URL: https://issues.apache.org/jira/browse/ARROW-2189
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: C++
>    Affects Versions: 0.8.0
>         Environment: Debian jessie in a Docker container
> libarrow-dev 0.8.0-2 (Ubuntu trusty)
>            Reporter: Rares Vernica
>            Priority: Major
>         Attachments: Dockerfile, foo.cpp
>
>
> When creating a {{PoolBuffer}}, I get a {{Segmentation fault}} when I use 
> {{make_shared}}. If I use the {{shared_ptr}} constructor of {{reset}}, it 
> works fine. Here is an example:
> {code:java}
> #include <arrow/builder.h>
> int main()
> {
>     arrow::MemoryPool* pool = arrow::default_memory_pool();
>     arrow::Int64Builder builder(pool);
>     builder.Append(1);
>     // #1
>     // std::shared_ptr<arrow::PoolBuffer> buffer(new arrow::PoolBuffer(pool));
>     // #2
>     // std::shared_ptr<arrow::PoolBuffer> buffer;
>     // buffer.reset(new arrow::PoolBuffer(pool));
>     // #3
>     auto buffer = std::make_shared<arrow::PoolBuffer>(pool);
> }
> {code}
> {code:java}
> > g++-4.9 -std=c++11 -larrow foo.cpp && ./a.out
> Segmentation fault (core dumped)
> {code}
> The example works fine with {{#1}} or {{#2}} options. It also works if the 
> builder is commented out.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to