[master] 5f93af1c6 vai: Consistency assertions

Nils Goroll nils.goroll at uplex.de
Mon Aug 4 10:56:05 UTC 2025


commit 5f93af1c618d0e4214cc7de967a0077efa8e4b5c
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Aug 4 12:44:32 2025 +0200

    vai: Consistency assertions
    
    Assert that the oc/boc pair remains the same throughout iteration
    
    Motivated by #4371

diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c
index 608533193..42ab4bf70 100644
--- a/bin/varnishd/storage/storage_simple.c
+++ b/bin/varnishd/storage/storage_simple.c
@@ -456,10 +456,13 @@ sml_ai_lease_boc(struct worker *wrk, vai_hdl vhdl, struct vscarab *scarab)
 
 	CAST_VAI_HDL_NOTNULL(hdl, vhdl, SML_HDL_MAGIC);
 	VSCARAB_CHECK_NOTNULL(scarab);
+	assert(hdl->boc == hdl->oc->boc);
+	assert(hdl->oc->stobj->priv == hdl->obj);
 
 	if (hdl->avail == hdl->returned) {
 		hdl->avail = ObjVAIGetExtend(wrk, hdl->oc, hdl->returned,
 		    &state, &hdl->qe);
+		assert(state >= BOS_STREAM);
 		if (state == BOS_FAILED) {
 			hdl->last = NULL;
 			return (-EPIPE);
@@ -497,6 +500,7 @@ sml_ai_lease_boc(struct worker *wrk, vai_hdl vhdl, struct vscarab *scarab)
 
 	while (hdl->avail > hdl->returned && (viov = VSCARAB_GET(scarab)) != NULL) {
 		CHECK_OBJ_NOTNULL(hdl->st, STORAGE_MAGIC); // ObjVAIGetExtend ensures
+		assert(hdl->boc == hdl->oc->boc);
 		assert(hdl->st_off <= hdl->st->space);
 		size_t av = hdl->avail - hdl->returned;
 		size_t l = hdl->st->space - hdl->st_off;


More information about the varnish-commit mailing list