Last active
April 11, 2018 06:59
-
-
Save alendit/f759bc12e03d9dd9d72cac90a6334cc5 to your computer and use it in GitHub Desktop.
BufferSlices crash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <arrow/buffer.h> | |
#include <memory> | |
#include <iostream> | |
using namespace arrow; | |
using namespace std; | |
auto main(int argc, char* argv[]) -> int { | |
auto pool_buffer = make_shared<PoolBuffer>(default_memory_pool()); | |
pool_buffer->Resize(16); | |
cout << "Initial parent data ptr: " << static_cast<const void*>(pool_buffer->data()) << "." << endl; | |
cout << "Size: " << pool_buffer->capacity() << "." << endl; | |
string data = "asdffdas"; | |
strcpy(reinterpret_cast<char*>(pool_buffer->mutable_data()), data.c_str()); | |
auto slice = SliceBuffer(pool_buffer, 0, 3); | |
cout << "From slice: " << slice->data() << "." << endl; | |
// force relocate | |
pool_buffer->Resize(512); | |
cout << "New parent data ptr: " << static_cast<const void*>(pool_buffer->data()) << "." << endl; | |
cout << "Slice data ptr: " << static_cast<const void*>(slice->data()) << "." << endl; | |
cout << "Again from slice: " << slice->data() << "." << endl; // BAM, read free'd address. | |
cout << "Everything's fine" << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment