diff options
author | ilnurkh <ilnurkh@yandex-team.com> | 2023-10-10 10:09:12 +0300 |
---|---|---|
committer | ilnurkh <ilnurkh@yandex-team.com> | 2023-10-10 10:26:34 +0300 |
commit | 335c640261b6272bc052a251d9b8780150090b45 (patch) | |
tree | 7d4a4954aacb63514087edaaf1cd0c9999fcb94d | |
parent | b359f0072dbc794d0287c26984dd0ea0a2c27efc (diff) | |
download | ydb-335c640261b6272bc052a251d9b8780150090b45.tar.gz |
Y_VERIFY->Y_ABORT_UNLESS at ^u
https://clubs.at.yandex-team.ru/arcadia/29404
30 files changed, 81 insertions, 81 deletions
diff --git a/util/folder/path.cpp b/util/folder/path.cpp index f2bc2a033a..29a1689870 100644 --- a/util/folder/path.cpp +++ b/util/folder/path.cpp @@ -199,7 +199,7 @@ TFsPath::TSplit& TFsPath::GetSplit() const { } static Y_FORCE_INLINE void VerifyPath(const TStringBuf path) { - Y_VERIFY(!path.Contains('\0'), "wrong format of TFsPath: %s", EscapeC(path).c_str()); + Y_ABORT_UNLESS(!path.Contains('\0'), "wrong format of TFsPath: %s", EscapeC(path).c_str()); } TFsPath::TFsPath() { diff --git a/util/folder/path_ut.cpp b/util/folder/path_ut.cpp index e450a88bae..bb0656ddbc 100644 --- a/util/folder/path_ut.cpp +++ b/util/folder/path_ut.cpp @@ -39,10 +39,10 @@ namespace { }; TTestDirectory::TTestDirectory(const TString& name) { - Y_VERIFY(name.length() > 0, "have to specify name"); - Y_VERIFY(name.find('.') == TString::npos, "must be simple name"); - Y_VERIFY(name.find('/') == TString::npos, "must be simple name"); - Y_VERIFY(name.find('\\') == TString::npos, "must be simple name"); + Y_ABORT_UNLESS(name.length() > 0, "have to specify name"); + Y_ABORT_UNLESS(name.find('.') == TString::npos, "must be simple name"); + Y_ABORT_UNLESS(name.find('/') == TString::npos, "must be simple name"); + Y_ABORT_UNLESS(name.find('\\') == TString::npos, "must be simple name"); Path_ = TFsPath(name); Path_.ForceDelete(); diff --git a/util/generic/bitmap.h b/util/generic/bitmap.h index 18a153bc5f..dfac88e4b8 100644 --- a/util/generic/bitmap.h +++ b/util/generic/bitmap.h @@ -170,7 +170,7 @@ namespace NBitMapPrivate { template <typename TOtherChunk> TFixedStorage(const TOtherChunk* data, size_t size) { - Y_VERIFY(Size * sizeof(TChunk) >= size * sizeof(TOtherChunk), "Exceeding bitmap storage capacity"); + Y_ABORT_UNLESS(Size * sizeof(TChunk) >= size * sizeof(TOtherChunk), "Exceeding bitmap storage capacity"); CopyData(Data, Size, data, size); } @@ -616,7 +616,7 @@ public: } Y_FORCE_INLINE void Reserve(size_t bitCount) { - Y_VERIFY(Mask.ExpandBitSize(bitCount), "Exceeding bitmap storage capacity"); + Y_ABORT_UNLESS(Mask.ExpandBitSize(bitCount), "Exceeding bitmap storage capacity"); } Y_FORCE_INLINE size_t ValueBitCount() const { @@ -967,7 +967,7 @@ public: void Load(IInputStream* inp) { ui8 chunkSize = 0; ::Load(inp, chunkSize); - Y_VERIFY(size_t(chunkSize) == sizeof(TChunk), "Chunk size is not the same"); + Y_ABORT_UNLESS(size_t(chunkSize) == sizeof(TChunk), "Chunk size is not the same"); ui64 bitCount64 = 0; ::Load(inp, bitCount64); diff --git a/util/generic/cast.h b/util/generic/cast.h index 0d4a41f385..7e130b6031 100644 --- a/util/generic/cast.h +++ b/util/generic/cast.h @@ -18,7 +18,7 @@ static inline T VerifyDynamicCast(F f) { T ret = dynamic_cast<T>(f); - Y_VERIFY(ret, "verify cast failed"); + Y_ABORT_UNLESS(ret, "verify cast failed"); return ret; } diff --git a/util/generic/flags.cpp b/util/generic/flags.cpp index 2ee52188a0..ced510d4fb 100644 --- a/util/generic/flags.cpp +++ b/util/generic/flags.cpp @@ -22,7 +22,7 @@ void ::NPrivate::PrintFlags(IOutputStream& stream, ui64 value, size_t size) { stream << Bin(static_cast<ui64>(value), HF_FULL); break; default: - Y_VERIFY(false); + Y_ABORT_UNLESS(false); } stream << ")"; diff --git a/util/generic/ptr_ut.cpp b/util/generic/ptr_ut.cpp index 6354d681bf..1e84e4fadb 100644 --- a/util/generic/ptr_ut.cpp +++ b/util/generic/ptr_ut.cpp @@ -806,7 +806,7 @@ public: } void DecRef() noexcept { - Y_VERIFY(--ExternalCounter_.Counter != 0); + Y_ABORT_UNLESS(--ExternalCounter_.Counter != 0); } private: diff --git a/util/generic/refcount.h b/util/generic/refcount.h index 77ad66a799..01300752aa 100644 --- a/util/generic/refcount.h +++ b/util/generic/refcount.h @@ -75,7 +75,7 @@ public: protected: inline void Check() const { - Y_VERIFY(ThreadId == SystemCurrentThreadId(), "incorrect usage of TSimpleCounter"); + Y_ABORT_UNLESS(ThreadId == SystemCurrentThreadId(), "incorrect usage of TSimpleCounter"); } private: diff --git a/util/generic/singleton.cpp b/util/generic/singleton.cpp index 35c18fddc4..df89d0a579 100644 --- a/util/generic/singleton.cpp +++ b/util/generic/singleton.cpp @@ -45,7 +45,7 @@ void NPrivate::FillWithTrash(void* ptr, size_t len) { void NPrivate::LockRecursive(std::atomic<size_t>& lock) noexcept { const size_t id = MyThreadId(); - Y_VERIFY(lock.load(std::memory_order_acquire) != id, "recursive singleton initialization"); + Y_ABORT_UNLESS(lock.load(std::memory_order_acquire) != id, "recursive singleton initialization"); if (!MyAtomicTryLock(lock, id)) { TSpinWait sw; @@ -57,6 +57,6 @@ void NPrivate::LockRecursive(std::atomic<size_t>& lock) noexcept { } void NPrivate::UnlockRecursive(std::atomic<size_t>& lock) noexcept { - Y_VERIFY(lock.load(std::memory_order_acquire) == MyThreadId(), "unlock from another thread?!?!"); + Y_ABORT_UNLESS(lock.load(std::memory_order_acquire) == MyThreadId(), "unlock from another thread?!?!"); lock.store(0); } diff --git a/util/network/pollerimpl.h b/util/network/pollerimpl.h index 0ec45e24f2..f92a6fb489 100644 --- a/util/network/pollerimpl.h +++ b/util/network/pollerimpl.h @@ -139,7 +139,7 @@ public: EV_SET(e + 0, fd, EVFILT_READ, EV_DELETE, 0, 0, 0); EV_SET(e + 1, fd, EVFILT_WRITE, EV_DELETE, 0, 0, 0); - Y_VERIFY(!(Kevent(Fd_, e, 2, nullptr, 0, nullptr) == -1 && errno != ENOENT), "kevent remove failed: %s", LastSystemErrorText()); + Y_ABORT_UNLESS(!(Kevent(Fd_, e, 2, nullptr, 0, nullptr) == -1 && errno != ENOENT), "kevent remove failed: %s", LastSystemErrorText()); } inline size_t Wait(TEvent* events, size_t len, int timeout) noexcept { @@ -150,7 +150,7 @@ public: const int ret = Kevent(Fd_, nullptr, 0, events, len, &ts); - Y_VERIFY(ret >= 0, "kevent failed: %s", LastSystemErrorText()); + Y_ABORT_UNLESS(ret >= 0, "kevent failed: %s", LastSystemErrorText()); return (size_t)ret; } @@ -277,7 +277,7 @@ public: inline size_t Wait(TEvent* events, size_t len, int timeout) noexcept { const int ret = ContEpollWait(Fd_, events, len, MicroToMilli(timeout)); - Y_VERIFY(ret >= 0, "epoll wait error: %s", LastSystemErrorText()); + Y_ABORT_UNLESS(ret >= 0, "epoll wait error: %s", LastSystemErrorText()); return (size_t)ret; } @@ -527,7 +527,7 @@ public: TryWait(); } - Y_VERIFY(ret >= 0 && (size_t)ret <= len, "select error: %s", LastSystemErrorText()); + Y_ABORT_UNLESS(ret >= 0 && (size_t)ret <= len, "select error: %s", LastSystemErrorText()); TEvent* eventsStart = events; diff --git a/util/network/sock.h b/util/network/sock.h index d5ebeccbb0..b9b73b2d37 100644 --- a/util/network/sock.h +++ b/util/network/sock.h @@ -580,7 +580,7 @@ protected: TStreamSocket* Socket; size_t DoRead(void* buf, size_t len) override { - Y_VERIFY(Socket, "TStreamSocketInput: socket isn't set"); + Y_ABORT_UNLESS(Socket, "TStreamSocketInput: socket isn't set"); const ssize_t ret = Socket->Recv(buf, len); if (ret >= 0) { @@ -608,7 +608,7 @@ protected: TStreamSocket* Socket; void DoWrite(const void* buf, size_t len) override { - Y_VERIFY(Socket, "TStreamSocketOutput: socket isn't set"); + Y_ABORT_UNLESS(Socket, "TStreamSocketOutput: socket isn't set"); const char* ptr = (const char*)buf; while (len) { diff --git a/util/network/socket.cpp b/util/network/socket.cpp index 4f6e804346..f6b1132222 100644 --- a/util/network/socket.cpp +++ b/util/network/socket.cpp @@ -561,9 +561,9 @@ void TSocketHolder::Close() noexcept { // because often it means double close // that is disasterous #ifdef _win_ - Y_VERIFY(WSAGetLastError() != WSAENOTSOCK, "must not quietly close bad socket descriptor"); + Y_ABORT_UNLESS(WSAGetLastError() != WSAENOTSOCK, "must not quietly close bad socket descriptor"); #elif defined(_unix_) - Y_VERIFY(errno != EBADF, "must not quietly close bad descriptor: fd=%d", int(Fd_)); + Y_ABORT_UNLESS(errno != EBADF, "must not quietly close bad descriptor: fd=%d", int(Fd_)); #else #error unsupported platform #endif diff --git a/util/network/socket_ut.cpp b/util/network/socket_ut.cpp index 6b20e11f70..4ae8f7d41e 100644 --- a/util/network/socket_ut.cpp +++ b/util/network/socket_ut.cpp @@ -132,12 +132,12 @@ class TTempEnableSigPipe { public: TTempEnableSigPipe() { OriginalSigHandler_ = signal(SIGPIPE, SIG_DFL); - Y_VERIFY(OriginalSigHandler_ != SIG_ERR); + Y_ABORT_UNLESS(OriginalSigHandler_ != SIG_ERR); } ~TTempEnableSigPipe() { auto ret = signal(SIGPIPE, OriginalSigHandler_); - Y_VERIFY(ret != SIG_ERR); + Y_ABORT_UNLESS(ret != SIG_ERR); } private: @@ -188,7 +188,7 @@ void TSockTest::TestClose() { void TSockTest::TestReusePortAvailCheck() { #if defined _linux_ utsname sysInfo; - Y_VERIFY(!uname(&sysInfo), "Error while call uname: %s", LastSystemErrorText()); + Y_ABORT_UNLESS(!uname(&sysInfo), "Error while call uname: %s", LastSystemErrorText()); TStringBuf release(sysInfo.release); release = release.substr(0, release.find_first_not_of(".0123456789")); int v1 = FromString<int>(release.NextTok('.')); diff --git a/util/random/common_ops.h b/util/random/common_ops.h index 602eede351..209e8dbb48 100644 --- a/util/random/common_ops.h +++ b/util/random/common_ops.h @@ -47,7 +47,7 @@ namespace NPrivate { */ template <class T, class TRandGen> static T GenUniform(T max, TRandGen&& gen) { - Y_VERIFY(max > 0, "Invalid random number range [0, 0)"); + Y_ABORT_UNLESS(max > 0, "Invalid random number range [0, 0)"); const T randmax = gen.RandMax() - gen.RandMax() % max; T rand; diff --git a/util/random/init_atfork.cpp b/util/random/init_atfork.cpp index 6f05d62b2c..4c9a7778d2 100644 --- a/util/random/init_atfork.cpp +++ b/util/random/init_atfork.cpp @@ -14,7 +14,7 @@ namespace { (void)&AtFork; #if defined(_unix_) - Y_VERIFY(pthread_atfork(nullptr, AtFork, nullptr) == 0, "it happens"); + Y_ABORT_UNLESS(pthread_atfork(nullptr, AtFork, nullptr) == 0, "it happens"); #endif } diff --git a/util/stream/buffer.cpp b/util/stream/buffer.cpp index d46a4e6c0b..ac4c85f288 100644 --- a/util/stream/buffer.cpp +++ b/util/stream/buffer.cpp @@ -21,7 +21,7 @@ public: } inline void DoUndo(size_t len) { - Y_VERIFY(len <= Data_.Size(), "trying to undo more bytes than actually written"); + Y_ABORT_UNLESS(len <= Data_.Size(), "trying to undo more bytes than actually written"); Data_.Resize(Data_.size() - len); } @@ -114,6 +114,6 @@ size_t TBufferInput::DoNext(const void** ptr, size_t len) { } void TBufferInput::DoUndo(size_t len) { - Y_VERIFY(len <= Readed_); + Y_ABORT_UNLESS(len <= Readed_); Readed_ -= len; } diff --git a/util/stream/buffered.cpp b/util/stream/buffered.cpp index a00e592e1c..c7d6647ec1 100644 --- a/util/stream/buffered.cpp +++ b/util/stream/buffered.cpp @@ -174,7 +174,7 @@ public: } inline void Undo(size_t len) { - Y_VERIFY(len <= Stored(), "trying to undo more bytes than actually written"); + Y_ABORT_UNLESS(len <= Stored(), "trying to undo more bytes than actually written"); MemOut_.Undo(len); } diff --git a/util/stream/str.cpp b/util/stream/str.cpp index 13f0e8ef28..a0c3b1c75c 100644 --- a/util/stream/str.cpp +++ b/util/stream/str.cpp @@ -12,7 +12,7 @@ size_t TStringInput::DoNext(const void** ptr, size_t len) { } void TStringInput::DoUndo(size_t len) { - Y_VERIFY(len <= Pos_); + Y_ABORT_UNLESS(len <= Pos_); Pos_ -= len; } @@ -29,7 +29,7 @@ size_t TStringOutput::DoNext(void** ptr) { } void TStringOutput::DoUndo(size_t len) { - Y_VERIFY(len <= S_->size(), "trying to undo more bytes than actually written"); + Y_ABORT_UNLESS(len <= S_->size(), "trying to undo more bytes than actually written"); S_->resize(S_->size() - len); } diff --git a/util/string/cast.cpp b/util/string/cast.cpp index 360551f068..b48c09396b 100644 --- a/util/string/cast.cpp +++ b/util/string/cast.cpp @@ -728,7 +728,7 @@ namespace { static inline size_t DoDtoa(double d, char* buf, size_t len, int prec) noexcept { TBuilder sb(buf, len); - Y_VERIFY(ToStringConverterNoPad().ToPrecision(d, prec, sb.SB), "conversion failed"); + Y_ABORT_UNLESS(ToStringConverterNoPad().ToPrecision(d, prec, sb.SB), "conversion failed"); return FixEnd(buf, FixZeros(buf, sb.SB->position())); } @@ -748,7 +748,7 @@ size_t FloatToString(float t, char* buf, size_t len, EFloatToStringMode mode, in if (mode == PREC_AUTO) { TBuilder sb(buf, len); - Y_VERIFY(ToStringConverterNoPad().ToShortestSingle(t, sb.SB), "conversion failed"); + Y_ABORT_UNLESS(ToStringConverterNoPad().ToShortestSingle(t, sb.SB), "conversion failed"); return FixEnd(buf, sb.SB->position()); } @@ -767,7 +767,7 @@ size_t FloatToString(double t, char* buf, size_t len, EFloatToStringMode mode, i TBuilder sb(buf, len); if (mode == PREC_AUTO) { - Y_VERIFY(ToStringConverterNoPad().ToShortest(t, sb.SB), "conversion failed"); + Y_ABORT_UNLESS(ToStringConverterNoPad().ToShortest(t, sb.SB), "conversion failed"); return FixEnd(buf, sb.SB->position()); } diff --git a/util/system/condvar.cpp b/util/system/condvar.cpp index a2031a89b8..b4d748e4e9 100644 --- a/util/system/condvar.cpp +++ b/util/system/condvar.cpp @@ -86,18 +86,18 @@ public: inline ~TImpl() { int ret = pthread_cond_destroy(&Cond_); - Y_VERIFY(ret == 0, "pthread_cond_destroy failed: %s", LastSystemErrorText(ret)); + Y_ABORT_UNLESS(ret == 0, "pthread_cond_destroy failed: %s", LastSystemErrorText(ret)); } inline void Signal() noexcept { int ret = pthread_cond_signal(&Cond_); - Y_VERIFY(ret == 0, "pthread_cond_signal failed: %s", LastSystemErrorText(ret)); + Y_ABORT_UNLESS(ret == 0, "pthread_cond_signal failed: %s", LastSystemErrorText(ret)); } inline bool WaitD(TMutex& lock, TInstant deadLine) noexcept { if (deadLine == TInstant::Max()) { int ret = pthread_cond_wait(&Cond_, (pthread_mutex_t*)lock.Handle()); - Y_VERIFY(ret == 0, "pthread_cond_wait failed: %s", LastSystemErrorText(ret)); + Y_ABORT_UNLESS(ret == 0, "pthread_cond_wait failed: %s", LastSystemErrorText(ret)); return true; } else { struct timespec spec; @@ -109,7 +109,7 @@ public: int ret = pthread_cond_timedwait(&Cond_, (pthread_mutex_t*)lock.Handle(), &spec); - Y_VERIFY(ret == 0 || ret == ETIMEDOUT, "pthread_cond_timedwait failed: %s", LastSystemErrorText(ret)); + Y_ABORT_UNLESS(ret == 0 || ret == ETIMEDOUT, "pthread_cond_timedwait failed: %s", LastSystemErrorText(ret)); return ret == 0; } @@ -117,7 +117,7 @@ public: inline void BroadCast() noexcept { int ret = pthread_cond_broadcast(&Cond_); - Y_VERIFY(ret == 0, "pthread_cond_broadcast failed: %s", LastSystemErrorText(ret)); + Y_ABORT_UNLESS(ret == 0, "pthread_cond_broadcast failed: %s", LastSystemErrorText(ret)); } private: diff --git a/util/system/direct_io.cpp b/util/system/direct_io.cpp index f59c54b0cb..1b6c39f42c 100644 --- a/util/system/direct_io.cpp +++ b/util/system/direct_io.cpp @@ -19,7 +19,7 @@ namespace { #ifdef _linux_ utsname sysInfo; - Y_VERIFY(!uname(&sysInfo), "Error while call uname: %s", LastSystemErrorText()); + Y_ABORT_UNLESS(!uname(&sysInfo), "Error while call uname: %s", LastSystemErrorText()); TStringBuf release(sysInfo.release); release = release.substr(0, release.find_first_not_of(".0123456789")); diff --git a/util/system/file.cpp b/util/system/file.cpp index 4a261d020c..761916efe5 100644 --- a/util/system/file.cpp +++ b/util/system/file.cpp @@ -66,7 +66,7 @@ static bool IsStupidFlagCombination(EOpenMode oMode) { TFileHandle::TFileHandle(const TString& fName, EOpenMode oMode) noexcept { ui32 fcMode = 0; EOpenMode createMode = oMode & MaskCreation; - Y_VERIFY(!IsStupidFlagCombination(oMode), "oMode %d makes no sense", static_cast<int>(oMode)); + Y_ABORT_UNLESS(!IsStupidFlagCombination(oMode), "oMode %d makes no sense", static_cast<int>(oMode)); if (!(oMode & MaskRW)) { oMode |= RdWr; } @@ -274,8 +274,8 @@ bool TFileHandle::Close() noexcept { isOk = (::CloseHandle(Fd_) != 0); } if (!isOk) { - Y_VERIFY(GetLastError() != ERROR_INVALID_HANDLE, - "must not quietly close invalid handle"); + Y_ABORT_UNLESS(GetLastError() != ERROR_INVALID_HANDLE, + "must not quietly close invalid handle"); } #elif defined(_unix_) if (Fd_ != INVALID_FHANDLE) { @@ -285,7 +285,7 @@ bool TFileHandle::Close() noexcept { // Do not quietly close bad descriptor, // because often it means double close // that is disasterous - Y_VERIFY(errno != EBADF, "must not quietly close bad descriptor: fd=%d", int(Fd_)); + Y_ABORT_UNLESS(errno != EBADF, "must not quietly close bad descriptor: fd=%d", int(Fd_)); } #else #error unsupported platform diff --git a/util/system/mutex.cpp b/util/system/mutex.cpp index acb6e87a1b..2850c6347b 100644 --- a/util/system/mutex.cpp +++ b/util/system/mutex.cpp @@ -35,7 +35,7 @@ public: inline ~T() { int result = pthread_mutexattr_destroy(&Attr); - Y_VERIFY(result == 0, "mutexattr destroy(%s)", LastSystemErrorText(result)); + Y_ABORT_UNLESS(result == 0, "mutexattr destroy(%s)", LastSystemErrorText(result)); } } pma; @@ -51,7 +51,7 @@ public: DeleteCriticalSection(&Obj); #else int result = pthread_mutex_destroy(&Obj); - Y_VERIFY(result == 0, "mutex destroy failure (%s)", LastSystemErrorText(result)); + Y_ABORT_UNLESS(result == 0, "mutex destroy failure (%s)", LastSystemErrorText(result)); #endif } @@ -60,7 +60,7 @@ public: EnterCriticalSection(&Obj); #else int result = pthread_mutex_lock(&Obj); - Y_VERIFY(result == 0, "mutex lock failure (%s)", LastSystemErrorText(result)); + Y_ABORT_UNLESS(result == 0, "mutex lock failure (%s)", LastSystemErrorText(result)); #endif } @@ -104,7 +104,7 @@ public: LeaveCriticalSection(&Obj); #else int result = pthread_mutex_unlock(&Obj); - Y_VERIFY(result == 0, "mutex unlock failure (%s)", LastSystemErrorText(result)); + Y_ABORT_UNLESS(result == 0, "mutex unlock failure (%s)", LastSystemErrorText(result)); #endif } diff --git a/util/system/protect.cpp b/util/system/protect.cpp index af8faf1bb1..6e435e648e 100644 --- a/util/system/protect.cpp +++ b/util/system/protect.cpp @@ -32,7 +32,7 @@ static TString ModeToString(const EProtectMemory mode) { } void ProtectMemory(void* addr, const size_t length, const EProtectMemory mode) { - Y_VERIFY(!(mode & ~(PM_READ | PM_WRITE | PM_EXEC)), "Invalid memory protection flag combination. "); + Y_ABORT_UNLESS(!(mode & ~(PM_READ | PM_WRITE | PM_EXEC)), "Invalid memory protection flag combination. "); #if defined(_unix_) || defined(_darwin_) int mpMode = PROT_NONE; diff --git a/util/system/rwlock.cpp b/util/system/rwlock.cpp index 60b0743acf..d4664d72d6 100644 --- a/util/system/rwlock.cpp +++ b/util/system/rwlock.cpp @@ -42,8 +42,8 @@ TRWMutex::TImpl::TImpl() } TRWMutex::TImpl::~TImpl() { - Y_VERIFY(State_ == 0, "failure, State_ != 0"); - Y_VERIFY(BlockedWriters_ == 0, "failure, BlockedWriters_ != 0"); + Y_ABORT_UNLESS(State_ == 0, "failure, State_ != 0"); + Y_ABORT_UNLESS(BlockedWriters_ == 0, "failure, BlockedWriters_ != 0"); } void TRWMutex::TImpl::AcquireRead() noexcept { @@ -173,44 +173,44 @@ TRWMutex::TImpl::TImpl() { TRWMutex::TImpl::~TImpl() { const int result = pthread_rwlock_destroy(&Lock_); - Y_VERIFY(result == 0, "rwlock destroy failed (%s)", LastSystemErrorText(result)); + Y_ABORT_UNLESS(result == 0, "rwlock destroy failed (%s)", LastSystemErrorText(result)); } void TRWMutex::TImpl::AcquireRead() noexcept { const int result = pthread_rwlock_rdlock(&Lock_); - Y_VERIFY(result == 0, "rwlock rdlock failed (%s)", LastSystemErrorText(result)); + Y_ABORT_UNLESS(result == 0, "rwlock rdlock failed (%s)", LastSystemErrorText(result)); } bool TRWMutex::TImpl::TryAcquireRead() noexcept { const int result = pthread_rwlock_tryrdlock(&Lock_); - Y_VERIFY(result == 0 || result == EBUSY, "rwlock tryrdlock failed (%s)", LastSystemErrorText(result)); + Y_ABORT_UNLESS(result == 0 || result == EBUSY, "rwlock tryrdlock failed (%s)", LastSystemErrorText(result)); return result == 0; } void TRWMutex::TImpl::ReleaseRead() noexcept { const int result = pthread_rwlock_unlock(&Lock_); - Y_VERIFY(result == 0, "rwlock (read) unlock failed (%s)", LastSystemErrorText(result)); + Y_ABORT_UNLESS(result == 0, "rwlock (read) unlock failed (%s)", LastSystemErrorText(result)); } void TRWMutex::TImpl::AcquireWrite() noexcept { const int result = pthread_rwlock_wrlock(&Lock_); - Y_VERIFY(result == 0, "rwlock wrlock failed (%s)", LastSystemErrorText(result)); + Y_ABORT_UNLESS(result == 0, "rwlock wrlock failed (%s)", LastSystemErrorText(result)); } bool TRWMutex::TImpl::TryAcquireWrite() noexcept { const int result = pthread_rwlock_trywrlock(&Lock_); - Y_VERIFY(result == 0 || result == EBUSY, "rwlock trywrlock failed (%s)", LastSystemErrorText(result)); + Y_ABORT_UNLESS(result == 0 || result == EBUSY, "rwlock trywrlock failed (%s)", LastSystemErrorText(result)); return result == 0; } void TRWMutex::TImpl::ReleaseWrite() noexcept { const int result = pthread_rwlock_unlock(&Lock_); - Y_VERIFY(result == 0, "rwlock (write) unlock failed (%s)", LastSystemErrorText(result)); + Y_ABORT_UNLESS(result == 0, "rwlock (write) unlock failed (%s)", LastSystemErrorText(result)); } void TRWMutex::TImpl::Release() noexcept { const int result = pthread_rwlock_unlock(&Lock_); - Y_VERIFY(result == 0, "rwlock unlock failed (%s)", LastSystemErrorText(result)); + Y_ABORT_UNLESS(result == 0, "rwlock unlock failed (%s)", LastSystemErrorText(result)); } #endif diff --git a/util/system/sem.cpp b/util/system/sem.cpp index ace53ddcff..1825ac3093 100644 --- a/util/system/sem.cpp +++ b/util/system/sem.cpp @@ -129,7 +129,7 @@ namespace { #else int ret = sem_post(Handle); #endif - Y_VERIFY(ret == 0, "can not release semaphore"); + Y_ABORT_UNLESS(ret == 0, "can not release semaphore"); #endif } @@ -137,7 +137,7 @@ namespace { //hence to maintain consistancy, for win32 case we use INFINITE or 0 timeout. inline void Acquire() noexcept { #ifdef _win_ - Y_VERIFY(::WaitForSingleObject(Handle, INFINITE) == WAIT_OBJECT_0, "can not acquire semaphore"); + Y_ABORT_UNLESS(::WaitForSingleObject(Handle, INFINITE) == WAIT_OBJECT_0, "can not acquire semaphore"); #else #ifdef USE_SYSV_SEMAPHORES struct sembuf ops[] = {{0, -1, SEM_UNDO}}; @@ -145,7 +145,7 @@ namespace { #else int ret = sem_wait(Handle); #endif - Y_VERIFY(ret == 0, "can not acquire semaphore"); + Y_ABORT_UNLESS(ret == 0, "can not acquire semaphore"); #endif } @@ -183,20 +183,20 @@ namespace { } inline ~TPosixSemaphore() { - Y_VERIFY(sem_destroy(&S_) == 0, "semaphore destroy failed"); + Y_ABORT_UNLESS(sem_destroy(&S_) == 0, "semaphore destroy failed"); } inline void Acquire() noexcept { - Y_VERIFY(sem_wait(&S_) == 0, "semaphore acquire failed"); + Y_ABORT_UNLESS(sem_wait(&S_) == 0, "semaphore acquire failed"); } inline void Release() noexcept { - Y_VERIFY(sem_post(&S_) == 0, "semaphore release failed"); + Y_ABORT_UNLESS(sem_post(&S_) == 0, "semaphore release failed"); } inline bool TryAcquire() noexcept { if (sem_trywait(&S_)) { - Y_VERIFY(errno == EAGAIN, "semaphore try wait failed"); + Y_ABORT_UNLESS(errno == EAGAIN, "semaphore try wait failed"); return false; } diff --git a/util/system/shmat.cpp b/util/system/shmat.cpp index 07ff0d6caa..f10a1268e7 100644 --- a/util/system/shmat.cpp +++ b/util/system/shmat.cpp @@ -170,7 +170,7 @@ static key_t GetKey(const TGUID& id) { } bool TSharedMemory::Open(const TGUID& id, int size) { - Y_VERIFY(id, "invalid shared memory guid: %s", GetGuidAsString(id).data()); + Y_ABORT_UNLESS(id, "invalid shared memory guid: %s", GetGuidAsString(id).data()); //Y_ASSERT(Data == 0); Size = size; diff --git a/util/system/thread.cpp b/util/system/thread.cpp index e9c3da3d11..e25ce5327f 100644 --- a/util/system/thread.cpp +++ b/util/system/thread.cpp @@ -443,13 +443,13 @@ namespace { // Should always succeed, unless something very strange is passed in `descr' void SetDescr(const char* descr) { auto hr = SetThreadDescription(GetCurrentThread(), (const WCHAR*)UTF8ToWide(descr).data()); - Y_VERIFY(SUCCEEDED(hr), "SetThreadDescription failed"); + Y_ABORT_UNLESS(SUCCEEDED(hr), "SetThreadDescription failed"); } TString GetDescr() { PWSTR wideName; auto hr = GetThreadDescription(GetCurrentThread(), &wideName); - Y_VERIFY(SUCCEEDED(hr), "GetThreadDescription failed"); + Y_ABORT_UNLESS(SUCCEEDED(hr), "GetThreadDescription failed"); Y_DEFER { LocalFree(wideName); }; @@ -499,14 +499,14 @@ TString TThread::CurrentThreadName() { // via `man prctl` char name[16]; memset(name, 0, sizeof(name)); - Y_VERIFY(prctl(PR_GET_NAME, name, 0, 0, 0) == 0, "pctl failed: %s", strerror(errno)); + Y_ABORT_UNLESS(prctl(PR_GET_NAME, name, 0, 0, 0) == 0, "pctl failed: %s", strerror(errno)); return name; #elif defined(_darwin_) // available on Mac OS 10.6+ const auto thread = pthread_self(); char name[256]; memset(name, 0, sizeof(name)); - Y_VERIFY(pthread_getname_np(thread, name, sizeof(name)) == 0, "pthread_getname_np failed: %s", strerror(errno)); + Y_ABORT_UNLESS(pthread_getname_np(thread, name, sizeof(name)) == 0, "pthread_getname_np failed: %s", strerror(errno)); return name; #elif defined(_win_) auto api = Singleton<TWinThreadDescrAPI>(); @@ -540,9 +540,9 @@ TCurrentThreadLimits::TCurrentThreadLimits() noexcept pthread_attr_init(&attr); #if defined(_linux_) || defined(_cygwin_) - Y_VERIFY(pthread_getattr_np(pthread_self(), &attr) == 0, "pthread_getattr failed"); + Y_ABORT_UNLESS(pthread_getattr_np(pthread_self(), &attr) == 0, "pthread_getattr failed"); #else - Y_VERIFY(pthread_attr_get_np(pthread_self(), &attr) == 0, "pthread_attr_get_np failed"); + Y_ABORT_UNLESS(pthread_attr_get_np(pthread_self(), &attr) == 0, "pthread_attr_get_np failed"); #endif pthread_attr_getstack(&attr, (void**)&StackBegin, &StackLength); pthread_attr_destroy(&attr); @@ -565,7 +565,7 @@ TCurrentThreadLimits::TCurrentThreadLimits() noexcept // Copied from https://github.com/llvm-mirror/compiler-rt/blob/release_40/lib/sanitizer_common/sanitizer_win.cc#L91 void* place_on_stack = alloca(16); MEMORY_BASIC_INFORMATION memory_info; - Y_VERIFY(VirtualQuery(place_on_stack, &memory_info, sizeof(memory_info))); + Y_ABORT_UNLESS(VirtualQuery(place_on_stack, &memory_info, sizeof(memory_info))); StackBegin = memory_info.AllocationBase; StackLength = static_cast<const char*>(memory_info.BaseAddress) + memory_info.RegionSize - static_cast<const char*>(StackBegin); diff --git a/util/system/tls.cpp b/util/system/tls.cpp index 9443aec3a3..40d748274e 100644 --- a/util/system/tls.cpp +++ b/util/system/tls.cpp @@ -122,14 +122,14 @@ namespace { class TMasterTls: public TGenericTlsBase { public: inline TMasterTls() { - Y_VERIFY(!pthread_key_create(&Key_, Dtor), "pthread_key_create failed"); + Y_ABORT_UNLESS(!pthread_key_create(&Key_, Dtor), "pthread_key_create failed"); } inline ~TMasterTls() override { //explicitly call dtor for main thread Dtor(pthread_getspecific(Key_)); - Y_VERIFY(!pthread_key_delete(Key_), "pthread_key_delete failed"); + Y_ABORT_UNLESS(!pthread_key_delete(Key_), "pthread_key_delete failed"); } static inline TMasterTls* Instance() { @@ -143,7 +143,7 @@ namespace { if (!ret) { ret = new TPerThreadStorage(); - Y_VERIFY(!pthread_setspecific(Key_, ret), "pthread_setspecific failed"); + Y_ABORT_UNLESS(!pthread_setspecific(Key_, ret), "pthread_setspecific failed"); } return (TPerThreadStorage*)ret; diff --git a/util/system/yassert_ut.cpp b/util/system/yassert_ut.cpp index ddd392666c..33c18bfb5d 100644 --- a/util/system/yassert_ut.cpp +++ b/util/system/yassert_ut.cpp @@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(YassertTest) { } Y_UNIT_TEST(TestVerify) { - Y_VERIFY(true, "hi %s", "there"); - Y_VERIFY(true); + Y_ABORT_UNLESS(true, "hi %s", "there"); + Y_ABORT_UNLESS(true); } } diff --git a/util/thread/pool.cpp b/util/thread/pool.cpp index 1711048f73..e312b6df47 100644 --- a/util/thread/pool.cpp +++ b/util/thread/pool.cpp @@ -293,7 +293,7 @@ private: // If you get an error here, it means you've used fork(2) in multi-threaded environment and probably created thread pools often. // Don't use fork(2) in multi-threaded programs, don't create thread pools often. // The mutex is locked after fork iff the fork(2) call was concurrent with RegisterObject / UnregisterObject in another thread. - Y_VERIFY(guard.WasAcquired(), "Failed to acquire ActionMutex after fork"); + Y_ABORT_UNLESS(guard.WasAcquired(), "Failed to acquire ActionMutex after fork"); for (auto it = RegisteredObjects.Begin(); it != RegisteredObjects.End(); ++it) { it->AtforkAction(); |