From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@dev.tarantool.org, alyapunov@tarantool.org, korablev@tarantool.org, tsafin@tarantool.org Subject: [Tarantool-patches] [PATCH v2 01/10] small: sanitized rlist and new region API Date: Thu, 28 May 2020 01:32:19 +0200 [thread overview] Message-ID: <ee96d01fe15bbf69c25c68dccb2140579e653a7b.1590622225.git.v.shpilevoy@tarantool.org> (raw) In-Reply-To: <cover.1590622225.git.v.shpilevoy@tarantool.org> Rlist used a hack to implement offsetof() leading to crash under undefined behaviour clang sanitizer. It was fixed in this update. Additionally, region_alloc_object() is changed to return the used size and a new macro region_alloc_array() is added. This small API change is supposed to simplify switching lots of region allocations to aligned versions in scope of #4609. Part of #4609 --- src/box/txn.c | 17 +++++++++-------- src/box/vy_write_iterator.c | 7 +++++-- src/lib/small | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/box/txn.c b/src/box/txn.c index 488aa4bdd..b81693c0a 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -54,11 +54,11 @@ static int txn_add_redo(struct txn *txn, struct txn_stmt *stmt, struct request *request) { /* Create a redo log row. */ + int size; struct xrow_header *row; - row = region_alloc_object(&txn->region, struct xrow_header); + row = region_alloc_object(&txn->region, struct xrow_header, &size); if (row == NULL) { - diag_set(OutOfMemory, sizeof(*row), - "region", "struct xrow_header"); + diag_set(OutOfMemory, size, "region_alloc_object", "row"); return -1; } if (request->header != NULL) { @@ -91,11 +91,11 @@ txn_add_redo(struct txn *txn, struct txn_stmt *stmt, struct request *request) static struct txn_stmt * txn_stmt_new(struct region *region) { + int size; struct txn_stmt *stmt; - stmt = region_alloc_object(region, struct txn_stmt); + stmt = region_alloc_object(region, struct txn_stmt, &size); if (stmt == NULL) { - diag_set(OutOfMemory, sizeof(*stmt), - "region", "struct txn_stmt"); + diag_set(OutOfMemory, size, "region_alloc_object", "stmt"); return NULL; } @@ -178,9 +178,10 @@ txn_new(void) region_create(®ion, &cord()->slabc); /* Place txn structure on the region. */ - struct txn *txn = region_alloc_object(®ion, struct txn); + int size; + struct txn *txn = region_alloc_object(®ion, struct txn, &size); if (txn == NULL) { - diag_set(OutOfMemory, sizeof(*txn), "region", "struct txn"); + diag_set(OutOfMemory, size, "region_alloc_object", "txn"); return NULL; } assert(region_used(®ion) == sizeof(*txn)); diff --git a/src/box/vy_write_iterator.c b/src/box/vy_write_iterator.c index 01962faa3..78a52ae5c 100644 --- a/src/box/vy_write_iterator.c +++ b/src/box/vy_write_iterator.c @@ -102,9 +102,12 @@ static inline struct vy_write_history * vy_write_history_new(struct vy_entry entry, struct vy_write_history *next) { struct vy_write_history *h; - h = region_alloc_object(&fiber()->gc, struct vy_write_history); - if (h == NULL) + int size; + h = region_alloc_object(&fiber()->gc, struct vy_write_history, &size); + if (h == NULL) { + diag_set(OutOfMemory, size, "region_alloc_object", "h"); return NULL; + } h->entry = entry; assert(next == NULL || (next->entry.stmt != NULL && vy_stmt_lsn(next->entry.stmt) > vy_stmt_lsn(entry.stmt))); diff --git a/src/lib/small b/src/lib/small index 118b53334..fc75e99f5 160000 --- a/src/lib/small +++ b/src/lib/small @@ -1 +1 @@ -Subproject commit 118b53334ad785ebe0534758832841dc2786fdc4 +Subproject commit fc75e99f5b2a695c9f52db78198ea7ada7ef6a82 -- 2.21.1 (Apple Git-122.3)
next prev parent reply other threads:[~2020-05-27 23:32 UTC|newest] Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-27 23:32 [Tarantool-patches] [PATCH v2 00/10] Sanitize unaligned access Vladislav Shpilevoy 2020-05-27 23:32 ` Vladislav Shpilevoy [this message] 2020-05-28 20:41 ` [Tarantool-patches] [PATCH v2 01/10] small: sanitized rlist and new region API Timur Safin 2020-05-28 22:56 ` Vladislav Shpilevoy 2020-06-08 23:01 ` Vladislav Shpilevoy 2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 10/10] xrow: use unaligned store operation in xrow_to_iovec() Vladislav Shpilevoy 2020-05-28 20:20 ` Timur Safin 2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 02/10] cmake: ignore warnings on alignof() and offsetof() Vladislav Shpilevoy 2020-05-28 20:18 ` Timur Safin 2020-05-29 6:24 ` Kirill Yukhin 2020-05-29 22:34 ` Vladislav Shpilevoy 2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 03/10] cmake: add option ENABLE_UB_SANITIZER Vladislav Shpilevoy 2020-05-28 20:42 ` Timur Safin 2020-05-29 8:53 ` Sergey Bronnikov 2020-05-29 22:36 ` Vladislav Shpilevoy 2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 04/10] crc32: align memory access Vladislav Shpilevoy 2020-05-28 20:11 ` Timur Safin 2020-05-28 23:23 ` Vladislav Shpilevoy 2020-05-28 23:32 ` Timur Safin 2020-06-08 22:33 ` Vladislav Shpilevoy 2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 05/10] sql: make BtCursor's memory aligned Vladislav Shpilevoy 2020-05-28 20:20 ` Timur Safin 2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 06/10] region: use aligned allocations where necessary Vladislav Shpilevoy 2020-05-28 20:35 ` Timur Safin 2020-05-28 23:07 ` Vladislav Shpilevoy 2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 07/10] vinyl: align statements and bps tree extents Vladislav Shpilevoy 2020-05-28 20:38 ` Timur Safin 2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 08/10] tuple: use unaligned store-load for field map Vladislav Shpilevoy 2020-05-28 20:22 ` Timur Safin 2020-05-27 23:32 ` [Tarantool-patches] [PATCH v2 09/10] port: make port_c_entry not PACKED Vladislav Shpilevoy 2020-05-28 20:42 ` Timur Safin 2020-06-03 21:27 ` [Tarantool-patches] [PATCH v2 00/10] Sanitize unaligned access Vladislav Shpilevoy 2020-06-08 22:33 ` Vladislav Shpilevoy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=ee96d01fe15bbf69c25c68dccb2140579e653a7b.1590622225.git.v.shpilevoy@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=alyapunov@tarantool.org \ --cc=korablev@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=tsafin@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 01/10] small: sanitized rlist and new region API' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox