I just tried it on Ubuntu again and got the same error: *** Error in `bin/zorba': free(): corrupted unsorted chunks: 0x0934e278 *** Here's the complete cmake call I used: cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-O2 -g" -DCMAKE_CXX_FLAGS="-O2 -g" -DCMAKE_CXX_FLAGS_RELEASE='-DNDEBUG' -DCMAKE_C_FLAGS_RELEASE='-DNDEBUG' .. The error occurs with query file test/rbkt/Queries/zorba/schemas/val-inplace2.xq, for example. "make doc" fails in my Ubuntu environment too (same error as mentioned above). $ valgrind ./zorba ../../test/rbkt/Queries/zorba/schemas/val-inplace2.xq ==30909== Memcheck, a memory error detector ==30909== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==30909== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info ==30909== Command: ./zorba ../../test/rbkt/Queries/zorba/schemas/val-inplace2.xq ==30909== ==30909== Invalid read of size 4 ==30909== at 0x492E873: zorba::store::Item::removeReference() (item.cpp:109) ==30909== by 0x46E08CC: zorba::NoaryBaseIterator::closeImpl(zorba::PlanState&) (item_handle.h:62) ==30909== by 0x467CE43: zorba::UnaryBaseIterator::closeImpl(zorba::PlanState&) (plan_iterator.h:450) ==30909== by 0x4763CEF: zorba::TransformIterator::closeImpl(zorba::PlanState&) (plan_iterator.h:450) ==30909== by 0x466CFA6: zorba::PlanWrapper::close() (plan_iterator.h:450) ==30909== by 0x4137FDE: zorba::XQueryImpl::dispose(zorba::rchandle const&) (xqueryimpl.cpp:726) ==30909== by 0x413D7CE: zorba::XQueryImpl::execute(std::ostream&, Zorba_SerializerOptions const*) (xqueryimpl.cpp:1145) ==30909== by 0x8057F35: compileAndExecute(zorba::Zorba*, zorba::SmartPtr&, std::string const&, std::istream&, std::ostream&, Timers&) (zorbacmd.cpp:525) ==30909== by 0x804D65A: main (zorbacmd.cpp:824) ==30909== Address 0x75b2990 is 8 bytes inside a block of size 216 free'd ==30909== at 0x402B838: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==30909== by 0x49B4011: zorba::simplestore::PULImpl::~PULImpl() (simple_pul.cpp:152) ==30909== by 0x492E5D3: zorba::store::Item::free() (item.cpp:49) ==30909== by 0x492E8B6: zorba::store::Item::removeReference() (item.cpp:211) ==30909== by 0x46E08CC: zorba::NoaryBaseIterator::closeImpl(zorba::PlanState&) (item_handle.h:62) ==30909== by 0x4763CDF: zorba::TransformIterator::closeImpl(zorba::PlanState&) (plan_iterator.h:450) ==30909== by 0x466CFA6: zorba::PlanWrapper::close() (plan_iterator.h:450) ==30909== by 0x4137FDE: zorba::XQueryImpl::dispose(zorba::rchandle const&) (xqueryimpl.cpp:726) ==30909== by 0x413D7CE: zorba::XQueryImpl::execute(std::ostream&, Zorba_SerializerOptions const*) (xqueryimpl.cpp:1145) ==30909== by 0x8057F35: compileAndExecute(zorba::Zorba*, zorba::SmartPtr&, std::string const&, std::istream&, std::ostream&, Timers&) (zorbacmd.cpp:525) ==30909== by 0x804D65A: main (zorbacmd.cpp:824) ==30909== ==30909== Invalid read of size 4 ==30909== at 0x492E8A8: zorba::store::Item::removeReference() (item.cpp:210) ==30909== by 0x46E08CC: zorba::NoaryBaseIterator::closeImpl(zorba::PlanState&) (item_handle.h:62) ==30909== by 0x467CE43: zorba::UnaryBaseIterator::closeImpl(zorba::PlanState&) (plan_iterator.h:450) ==30909== by 0x4763CEF: zorba::TransformIterator::closeImpl(zorba::PlanState&) (plan_iterator.h:450) ==30909== by 0x466CFA6: zorba::PlanWrapper::close() (plan_iterator.h:450) ==30909== by 0x4137FDE: zorba::XQueryImpl::dispose(zorba::rchandle const&) (xqueryimpl.cpp:726) ==30909== by 0x413D7CE: zorba::XQueryImpl::execute(std::ostream&, Zorba_SerializerOptions const*) (xqueryimpl.cpp:1145) ==30909== by 0x8057F35: compileAndExecute(zorba::Zorba*, zorba::SmartPtr&, std::string const&, std::istream&, std::ostream&, Timers&) (zorbacmd.cpp:525) ==30909== by 0x804D65A: main (zorbacmd.cpp:824) ==30909== Address 0x75b298c is 4 bytes inside a block of size 216 free'd ==30909== at 0x402B838: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==30909== by 0x49B4011: zorba::simplestore::PULImpl::~PULImpl() (simple_pul.cpp:152) ==30909== by 0x492E5D3: zorba::store::Item::free() (item.cpp:49) ==30909== by 0x492E8B6: zorba::store::Item::removeReference() (item.cpp:211) ==30909== by 0x46E08CC: zorba::NoaryBaseIterator::closeImpl(zorba::PlanState&) (item_handle.h:62) ==30909== by 0x4763CDF: zorba::TransformIterator::closeImpl(zorba::PlanState&) (plan_iterator.h:450) ==30909== by 0x466CFA6: zorba::PlanWrapper::close() (plan_iterator.h:450) ==30909== by 0x4137FDE: zorba::XQueryImpl::dispose(zorba::rchandle const&) (xqueryimpl.cpp:726) ==30909== by 0x413D7CE: zorba::XQueryImpl::execute(std::ostream&, Zorba_SerializerOptions const*) (xqueryimpl.cpp:1145) ==30909== by 0x8057F35: compileAndExecute(zorba::Zorba*, zorba::SmartPtr&, std::string const&, std::istream&, std::ostream&, Timers&) (zorbacmd.cpp:525) ==30909== by 0x804D65A: main (zorbacmd.cpp:824) ==30909== DDType==30909== ==30909== HEAP SUMMARY: ==30909== in use at exit: 0 bytes in 0 blocks ==30909== total heap usage: 15,125 allocs, 15,125 frees, 5,212,412 bytes allocated ==30909== ==30909== All heap blocks were freed -- no leaks are possible ==30909== ==30909== For counts of detected and suppressed errors, rerun with: -v ==30909== ERROR SUMMARY: 3 errors from 2 contexts (suppressed: 0 from 0)