diff options
20 files changed, 87 insertions, 35 deletions
diff --git a/document/src/vespa/document/select/result.h b/document/src/vespa/document/select/result.h index 157121b43dd..4e30cb5a8af 100644 --- a/document/src/vespa/document/select/result.h +++ b/document/src/vespa/document/select/result.h @@ -20,6 +20,7 @@ #pragma once #include <assert.h> +#include <vespa/vespalib/util/hdr_abort.h> #include <vespa/document/util/printable.h> namespace document::select { @@ -49,7 +50,7 @@ public: return 1u; if (this == &Result::True) return 2u; - assert(false); abort(); + HDR_ABORT("should not be reached"); } static const Result &fromEnum(uint32_t val) { @@ -59,7 +60,7 @@ public: return Result::False; if (val == 2u) return Result::True; - assert(false); abort(); + HDR_ABORT("should not be reached"); } private: diff --git a/eval/src/vespa/eval/eval/basic_nodes.h b/eval/src/vespa/eval/eval/basic_nodes.h index e6caf052367..95e6cdf34f7 100644 --- a/eval/src/vespa/eval/eval/basic_nodes.h +++ b/eval/src/vespa/eval/eval/basic_nodes.h @@ -2,7 +2,7 @@ #pragma once -#include <vespa/log/log.h> +#include <vespa/vespalib/util/hdr_abort.h> #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/util/string_hash.h> @@ -81,7 +81,7 @@ const T *as(const Node &node) { return dynamic_cast<const T *>(&node); } struct Leaf : public Node { size_t num_children() const override { return 0; } const Node &get_child(size_t) const override { - LOG_ABORT("should not be reached"); + HDR_ABORT("should not be reached"); } void detach_children(NodeHandler &) override {} }; diff --git a/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h b/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h index 341e443b218..89370458136 100644 --- a/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h +++ b/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h @@ -2,7 +2,7 @@ #pragma once -#include <vespa/log/log.h> +#include <vespa/vespalib/util/hdr_abort.h> #include <vespa/eval/tensor/direct_tensor_builder.h> #include "sparse_tensor.h" #include "sparse_tensor_address_builder.h" @@ -106,7 +106,7 @@ public: void insertCell(SparseTensorAddressRef address, double value) { // This address should not already exist and a new cell should be inserted. - insertCell(address, value, [](double, double) -> double { LOG_ABORT("should not be reached"); }); + insertCell(address, value, [](double, double) -> double { HDR_ABORT("should not be reached"); }); } template <class Function> @@ -117,7 +117,7 @@ public: void insertCell(SparseTensorAddressBuilder &address, double value) { // This address should not already exist and a new cell should be inserted. - insertCell(address.getAddressRef(), value, [](double, double) -> double { LOG_ABORT("should not be reached"); }); + insertCell(address.getAddressRef(), value, [](double, double) -> double { HDR_ABORT("should not be reached"); }); } eval::ValueType &fast_type() { return _type; } diff --git a/fastlib/src/vespa/fastlib/io/bufferedfile.h b/fastlib/src/vespa/fastlib/io/bufferedfile.h index a1f69404896..ccb9644b49b 100644 --- a/fastlib/src/vespa/fastlib/io/bufferedfile.h +++ b/fastlib/src/vespa/fastlib/io/bufferedfile.h @@ -2,6 +2,7 @@ #pragma once +#include <vespa/vespalib/util/hdr_abort.h> #include <vespa/vespalib/util/alloc.h> #include <vespa/fastos/file.h> @@ -87,7 +88,7 @@ public: * or reads as much as possible if the (rest of) the file * is smaller than the buffer. * Caution: If the amount read is smaller than the expected - * amount, the method will LOG_ABORT("should not be reached"). + * amount, the method will abort. */ void fillReadBuf(void); /** diff --git a/juniper/src/vespa/juniper/SummaryConfig.h b/juniper/src/vespa/juniper/SummaryConfig.h index 77e7b77e004..4a6a56fad9c 100644 --- a/juniper/src/vespa/juniper/SummaryConfig.h +++ b/juniper/src/vespa/juniper/SummaryConfig.h @@ -27,6 +27,8 @@ public: ConfigFlag esc_markup, ConfigFlag preserve_white_space_); + ~SummaryConfig() {} + inline const std::string & highlight_on() const { return _highlight_on; } inline const std::string & highlight_off() const { return _highlight_off; } inline const std::string & dots() const { return _dots; } diff --git a/juniper/src/vespa/juniper/appender.h b/juniper/src/vespa/juniper/appender.h index 39ea3a649fb..3afb8b1494d 100644 --- a/juniper/src/vespa/juniper/appender.h +++ b/juniper/src/vespa/juniper/appender.h @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -/* $Id: */ +#include <vespa/vespalib/util/hdr_abort.h> namespace juniper { @@ -119,7 +119,7 @@ public: _sumconf->dots()[0] == '<'); break; default: - assert(false); + HDR_ABORT("should not be reached"); break; } diff --git a/searchcore/src/vespa/searchcore/proton/test/attribute_utils.h b/searchcore/src/vespa/searchcore/proton/test/attribute_utils.h index 6270b8b3a89..f1d661a3ad0 100644 --- a/searchcore/src/vespa/searchcore/proton/test/attribute_utils.h +++ b/searchcore/src/vespa/searchcore/proton/test/attribute_utils.h @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include <vespa/vespalib/util/hdr_abort.h> #include <vespa/searchcommon/attribute/config.h> #include <vespa/searchlib/attribute/integerbase.h> @@ -24,7 +25,7 @@ struct AttributeUtils search::IntegerAttribute &ia = static_cast<search::IntegerAttribute &>(*attr); while (ia.getNumDocs() < to) { uint32_t docId; - if (!ia.addDoc(docId)) { LOG_ABORT("should not be reached"); } + if (!ia.addDoc(docId)) { HDR_ABORT("should not be reached"); } } for (uint32_t i = from; i < to; ++i) { ia.update(i, value); diff --git a/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h b/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h index 9385c160927..b0b999e0d30 100644 --- a/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h +++ b/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h @@ -1,6 +1,7 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include <vespa/vespalib/util/hdr_abort.h> #include <vespa/searchlib/test/mock_attribute_manager.h> #include <vespa/searchcore/proton/attribute/i_attribute_manager.h> #include <vespa/searchcore/proton/attribute/imported_attributes_repo.h> @@ -54,16 +55,16 @@ public: virtual void pruneRemovedFields(search::SerialNum) override { } virtual const IAttributeFactory::SP &getFactory() const override { - LOG_ABORT("should not be reached"); + HDR_ABORT("should not be reached"); } virtual search::ISequencedTaskExecutor &getAttributeFieldWriter() const override { - LOG_ABORT("should not be reached"); + HDR_ABORT("should not be reached"); } virtual search::AttributeVector *getWritableAttribute(const vespalib::string &) const override { return nullptr; } virtual const std::vector<search::AttributeVector *> &getWritableAttributes() const override { - LOG_ABORT("should not be reached"); + HDR_ABORT("should not be reached"); } virtual void asyncForEachAttribute(std::shared_ptr<IAttributeFunctor>) const override { } diff --git a/searchlib/src/tests/attribute/benchmark/attributeupdater.h b/searchlib/src/tests/attribute/benchmark/attributeupdater.h index 1b493dabcc7..1dad2cb563d 100644 --- a/searchlib/src/tests/attribute/benchmark/attributeupdater.h +++ b/searchlib/src/tests/attribute/benchmark/attributeupdater.h @@ -2,6 +2,7 @@ #pragma once +#include <vespa/vespalib/util/hdr_abort.h> #include <vespa/searchlib/util/randomgenerator.h> #include <vespa/searchlib/util/runnable.h> #include <vespa/searchlib/attribute/attribute.h> @@ -25,7 +26,7 @@ public: if (!rc) { std::cout << "Assert " << _totalCnt << " failed: \"" << str << "\" (" << file << ":" << line << ")" << std::endl; - LOG_ABORT("should not be reached"); + HDR_ABORT("should not be reached"); } return true; } @@ -39,7 +40,7 @@ public: std::cout << aStr << ": " << a << std::endl; std::cout << bStr << ": " << b << std::endl; std::cout << "(" << file << ":" << line << ")" << std::endl; - LOG_ABORT("should not be reached"); + HDR_ABORT("should not be reached"); } return true; } diff --git a/searchlib/src/vespa/searchlib/attribute/attrvector.hpp b/searchlib/src/vespa/searchlib/attribute/attrvector.hpp index 08b54e9d561..565801b1b0c 100644 --- a/searchlib/src/vespa/searchlib/attribute/attrvector.hpp +++ b/searchlib/src/vespa/searchlib/attribute/attrvector.hpp @@ -2,6 +2,7 @@ #pragma once #include "attrvector.h" +#include <vespa/vespalib/util/hdr_abort.h> #include <vespa/fastlib/io/bufferedfile.h> #include <vespa/searchlib/util/filekit.h> @@ -130,7 +131,7 @@ template <typename B> void NumericDirectAttribute<B>::onCommit() { B::_changes.clear(); - LOG_ABORT("should not be reached"); + HDR_ABORT("should not be reached"); } template <typename B> diff --git a/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp index c3cd9d56717..1bca7b9b9e3 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp @@ -2,6 +2,7 @@ #pragma once +#include <vespa/vespalib/util/hdr_abort.h> #include <vespa/searchlib/attribute/enumattribute.h> #include <vespa/searchlib/attribute/enumstore.hpp> @@ -109,7 +110,7 @@ EnumAttribute<B>::insertNewUniqueValues(EnumStoreBase::IndexVector & newIndexes) this->_enumStore.fallbackResize(extraBytesNeeded); if (extraBytesNeeded > this->_enumStore.getRemaining()) { fprintf(stderr, "Cannot fallbackResize enumStore\n"); - LOG_ABORT("should not be reached"); + HDR_ABORT("should not be reached"); } break; // fallback resize performed instead of compaction. } diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp index 95358beb11d..3a2ac451712 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp +++ b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp @@ -5,6 +5,7 @@ #include "enumstore.h" #include "enumcomparator.h" +#include <vespa/vespalib/util/hdr_abort.h> #include <vespa/searchlib/btree/btreenode.hpp> #include <vespa/searchlib/btree/btreenodestore.hpp> #include <vespa/searchlib/btree/btreenodeallocator.hpp> @@ -151,7 +152,7 @@ EnumStoreT<EntryType>::deserialize(const void *src, datastore::BufferState & buffer = _store.getBufferState(activeBufferId); uint32_t entrySize(alignEntrySize(EntryBase::size() + sz)); if (buffer.remaining() < entrySize) { - LOG_ABORT("should not be reached"); // not enough space + HDR_ABORT("should not be reached"); // not enough space } uint64_t offset = buffer.size(); char *dst(_store.getBufferEntry<char>(activeBufferId, offset)); @@ -256,7 +257,7 @@ EnumStoreT<EntryType>::addEnum(Type value, buffer._deadElems, entrySize); #endif if (buffer.remaining() < entrySize) { - LOG_ABORT("should not be reached"); // not enough space + HDR_ABORT("should not be reached"); // not enough space } // check if already present diff --git a/searchlib/src/vespa/searchlib/btree/btreeiterator.hpp b/searchlib/src/vespa/searchlib/btree/btreeiterator.hpp index 33bc228653d..18635dda546 100644 --- a/searchlib/src/vespa/searchlib/btree/btreeiterator.hpp +++ b/searchlib/src/vespa/searchlib/btree/btreeiterator.hpp @@ -5,6 +5,7 @@ #include "btreeiterator.h" #include "btreeaggregator.h" #include "btreenode.hpp" +#include <vespa/vespalib/util/hdr_abort.h> #include <vespa/vespalib/stllike/asciistream.h> namespace search { @@ -557,17 +558,17 @@ BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>:: identical(const BTreeIteratorBase &rhs) const { if (_pathSize != rhs._pathSize || _leaf != rhs._leaf) { - LOG_ABORT("should not be reached"); + HDR_ABORT("should not be reached"); return false; } for (uint32_t level = 0; level < _pathSize; ++level) { if (_path[level] != rhs._path[level]) { - LOG_ABORT("should not be reached"); + HDR_ABORT("should not be reached"); return false; } } if (_leafRoot != rhs._leafRoot) { - LOG_ABORT("should not be reached"); + HDR_ABORT("should not be reached"); return false; } return true; diff --git a/storage/src/vespa/storage/bucketdb/judymultimap.hpp b/storage/src/vespa/storage/bucketdb/judymultimap.hpp index 81a58582073..0d80bcfb28e 100644 --- a/storage/src/vespa/storage/bucketdb/judymultimap.hpp +++ b/storage/src/vespa/storage/bucketdb/judymultimap.hpp @@ -2,7 +2,7 @@ #pragma once #include "judymultimap.h" -#include <vespa/log/log.h> +#include <vespa/vespalib/util/hdr_abort.h> #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/array.hpp> #include <set> @@ -151,7 +151,7 @@ JudyMultiMap<T0, T1, T2, T3>::operator[](key_type key) case 1: return _values1[getIndex(it.value())]; case 2: return _values2[getIndex(it.value())]; case 3: return _values3[getIndex(it.value())]; - default: LOG_ABORT("should not be reached"); + default: HDR_ABORT("should not be reached"); } return T0(); // Avoid warning of no return } @@ -290,8 +290,7 @@ JudyMultiMap<T0, T1, T2, T3>::ConstIterator::operator*() const case 3: return value_type( _iterator.key(), _parent->_values3[getIndex(_iterator.value())]); default: - assert(false); - LOG_ABORT("should not be reached"); + HDR_ABORT("should not be reached"); } } @@ -300,11 +299,12 @@ typename JudyMultiMap<T0, T1, T2, T3>::mapped_type JudyMultiMap<T0, T1, T2, T3>::ConstIterator::value() const { switch (getType(_iterator.value())) { - default: assert(false); case 0: return _parent->_values0[getIndex(_iterator.value())]; case 1: return _parent->_values1[getIndex(_iterator.value())]; case 2: return _parent->_values2[getIndex(_iterator.value())]; case 3: return _parent->_values3[getIndex(_iterator.value())]; + default: + HDR_ABORT("should not be reached"); } } diff --git a/storage/src/vespa/storage/bucketdb/lockablemap.hpp b/storage/src/vespa/storage/bucketdb/lockablemap.hpp index f370a792145..6d700cd6049 100644 --- a/storage/src/vespa/storage/bucketdb/lockablemap.hpp +++ b/storage/src/vespa/storage/bucketdb/lockablemap.hpp @@ -2,6 +2,7 @@ #pragma once #include "lockablemap.h" +#include <vespa/vespalib/util/hdr_abort.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/vespalib/stllike/hash_set.hpp> @@ -264,7 +265,8 @@ LockableMap<Map>::handleDecision(key_type& key, mapped_type& val, break; case ABORT: return true; case CONTINUE: break; - default: assert(false); + default: + HDR_ABORT("should not be reached"); } return false; } diff --git a/storage/src/vespa/storage/distributor/operations/external/statbucketlistoperation.h b/storage/src/vespa/storage/distributor/operations/external/statbucketlistoperation.h index 0fbf3bb9e81..c977ea78f67 100644 --- a/storage/src/vespa/storage/distributor/operations/external/statbucketlistoperation.h +++ b/storage/src/vespa/storage/distributor/operations/external/statbucketlistoperation.h @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include <vespa/vespalib/util/hdr_abort.h> #include <vespa/storage/distributor/operations/operation.h> #include <vespa/storage/bucketdb/bucketdatabase.h> #include <vespa/vespalib/util/sync.h> @@ -30,7 +31,7 @@ public: void onReceive(DistributorMessageSender&, const std::shared_ptr<api::StorageReply>&) override { // Never called. - assert(false); + HDR_ABORT("should not be reached"); } void onClose(DistributorMessageSender&) override {} diff --git a/storage/src/vespa/storage/distributor/throttlingoperationstarter.h b/storage/src/vespa/storage/distributor/throttlingoperationstarter.h index c6e39a083b1..0b6d89e0570 100644 --- a/storage/src/vespa/storage/distributor/throttlingoperationstarter.h +++ b/storage/src/vespa/storage/distributor/throttlingoperationstarter.h @@ -2,6 +2,7 @@ #pragma once #include "operationstarter.h" +#include <vespa/vespalib/util/hdr_abort.h> #include <vespa/storage/distributor/operations/operation.h> namespace storage::distributor { @@ -49,11 +50,11 @@ class ThrottlingOperationStarter : public OperationStarter void onStart(DistributorMessageSender&) override { // Should never be called directly on the throttled operation // instance, but rather on its wrapped implementation. - assert(false); + HDR_ABORT("should not be reached"); } void onReceive(DistributorMessageSender&, const std::shared_ptr<api::StorageReply>&) override { - assert(false); + HDR_ABORT("should not be reached"); } }; diff --git a/vespalib/src/vespa/vespalib/util/CMakeLists.txt b/vespalib/src/vespa/vespalib/util/CMakeLists.txt index 58739ee4df6..f71a5fa26e9 100644 --- a/vespalib/src/vespa/vespalib/util/CMakeLists.txt +++ b/vespalib/src/vespa/vespalib/util/CMakeLists.txt @@ -23,6 +23,7 @@ vespa_add_library(vespalib_vespalib_util OBJECT generationhandler.cpp generationholder.cpp hashmap.cpp + hdr_abort.cpp host_name.cpp joinable.cpp left_right_heap.cpp @@ -42,12 +43,12 @@ vespa_add_library(vespalib_vespalib_util OBJECT simple_thread_bundle.cpp slaveproc.cpp stash.cpp - string_hash.cpp stringfmt.cpp - thread.cpp + string_hash.cpp thread_bundle.cpp - threadstackexecutor.cpp + thread.cpp threadstackexecutorbase.cpp + threadstackexecutor.cpp time_tracker.cpp valgrind.cpp zstdcompressor.cpp diff --git a/vespalib/src/vespa/vespalib/util/hdr_abort.cpp b/vespalib/src/vespa/vespalib/util/hdr_abort.cpp new file mode 100644 index 00000000000..e0c46992f3b --- /dev/null +++ b/vespalib/src/vespa/vespalib/util/hdr_abort.cpp @@ -0,0 +1,23 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "hdr_abort.h" +#include <cstdlib> +#include <cstdio> + +#include <vespa/log/log.h> +LOG_SETUP(".vespalib"); + +namespace vespalib { + +void hdr_abort(const char *message, + const char *file, + unsigned int line) +{ + LOG(error, "%s:%d: Abort called. Reason: %s", + file, line, message); + fprintf(stderr, "%s:%d: Abort called. Reason: %s\n", + file, line, message); + abort(); +} + +} // namespace vespalib diff --git a/vespalib/src/vespa/vespalib/util/hdr_abort.h b/vespalib/src/vespa/vespalib/util/hdr_abort.h new file mode 100644 index 00000000000..f6fbb8ffbb0 --- /dev/null +++ b/vespalib/src/vespa/vespalib/util/hdr_abort.h @@ -0,0 +1,13 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +namespace vespalib { + +extern void hdr_abort(const char *message, + const char *file, + unsigned int line) __attribute__((__noreturn__)); + +#define HDR_ABORT(msg) \ + (vespalib::hdr_abort(msg, __FILE__, __LINE__)) + +} // namespace vespalib |