diff --git a/src/libpmemobj/tx.c b/src/libpmemobj/tx.c index 774fa06e3de..63b61f91ec0 100644 --- a/src/libpmemobj/tx.c +++ b/src/libpmemobj/tx.c @@ -1829,7 +1829,7 @@ pmemobj_tx_add_common(struct tx *tx, struct tx_range_def *args) * snapshot and resume the search from the end of the found * offset. */ - do { + while (r.size != 0) { n = ravl_find(runtime->ranges, &r, RAVL_PREDICATE_GREATER_EQUAL); f = n ? ravl_data(n) : NULL; @@ -1876,7 +1876,7 @@ pmemobj_tx_add_common(struct tx *tx, struct tx_range_def *args) * finish... */ r.size = offd < args->size ? args->size - offd : 0; - } while (r.size != 0); + } if (ret != 0) { ERR("out of memory"); diff --git a/src/test/obj_tx_add_range/obj_tx_add_range.c b/src/test/obj_tx_add_range/obj_tx_add_range.c index 1ab34cd5166..3e985b526db 100644 --- a/src/test/obj_tx_add_range/obj_tx_add_range.c +++ b/src/test/obj_tx_add_range/obj_tx_add_range.c @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017, Intel Corporation + * Copyright 2015-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -85,7 +85,7 @@ struct overlap_object { * do_tx_alloc -- do tx allocation with specified type number */ static PMEMoid -do_tx_zalloc(PMEMobjpool *pop, int type_num) +do_tx_zalloc(PMEMobjpool *pop, uint64_t type_num) { PMEMoid ret = OID_NULL; @@ -620,6 +620,21 @@ do_tx_add_range_too_large(PMEMobjpool *pop) UT_ASSERTne(errno, 0); } +static void +do_tx_add_range_zero(PMEMobjpool *pop) +{ + TOID(struct object) obj; + TOID_ASSIGN(obj, do_tx_zalloc(pop, TYPE_OBJ)); + + TX_BEGIN(pop) { + pmemobj_tx_add_range(obj.oid, 0, 0); + } TX_ONABORT { + UT_ASSERT(0); + } TX_END + + UT_ASSERTne(errno, 0); +} + int main(int argc, char *argv[]) { @@ -664,6 +679,8 @@ main(int argc, char *argv[]) VALGRIND_WRITE_STATS; do_tx_add_huge_range_abort(pop); VALGRIND_WRITE_STATS; + do_tx_add_range_zero(pop); + VALGRIND_WRITE_STATS; do_tx_xadd_range_commit(pop); pmemobj_close(pop); } diff --git a/src/test/obj_tx_add_range/pmemcheck1.log.match b/src/test/obj_tx_add_range/pmemcheck1.log.match index 6ebe712172e..e801c7dde3d 100644 --- a/src/test/obj_tx_add_range/pmemcheck1.log.match +++ b/src/test/obj_tx_add_range/pmemcheck1.log.match @@ -40,6 +40,9 @@ ==$(*)== Number of stores not made persistent: 0 ==$(*)== ERROR SUMMARY: 0 errors ==$(*)== +==$(*)== Number of stores not made persistent: 0 +==$(*)== ERROR SUMMARY: 0 errors +==$(*)== ==$(*)== ==$(*)== Number of stores not made persistent: 1 ==$(*)== Stores not made persistent properly: