Skip to content

Commit 93c5fb9

Browse files
committed
Catch exceptions inside c4queryobs_setEnabled()
Speculative fix for intermittent crash observed by a customer. This API function calls into C4Query::enableObserver(), which is a pretty complex method that is not marked `noexcept`, so it's possible it sometimes throws, causing the crash in `std::terminate` seen in customer's crash logs.
1 parent 1fbd91d commit 93c5fb9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

C/c4CAPI.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,12 @@ C4QueryObserver* c4queryobs_create(C4Query* query, C4QueryObserverCallback cb, v
936936
});
937937
}
938938

939-
void c4queryobs_setEnabled(C4QueryObserver* obs, bool enabled) noexcept { obs->setEnabled(enabled); }
939+
void c4queryobs_setEnabled(C4QueryObserver* obs, bool enabled) noexcept {
940+
try {
941+
obs->setEnabled(enabled);
942+
}
943+
catchAndWarn();
944+
}
940945

941946
void c4queryobs_free(C4QueryObserver* obs) noexcept {
942947
if ( obs ) {

0 commit comments

Comments
 (0)