From e9d6dca45043d12c313783637bef6699f8589db0 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov <kostja@tarantool.org> Date: Sat, 30 Jun 2012 11:02:50 +0400 Subject: [PATCH] Fix test suite crashes with libobjc2 runtime. libobjc2 has a notion of "small objects". The type of a small object is detected by checking its address: it should not be word-aligned. When performing a custom memory allocation for Request, make sure it's not a small object, by aligning it around (void *) pointer (word) boundary. object_dispose in libobjc2 runtime doesn't check whether the passed in object is nil, so check for nil outside. --- mod/box/box_lua.m | 2 +- mod/box/request.m | 2 +- src/exception.m | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mod/box/box_lua.m b/mod/box/box_lua.m index 6ad5bfe270..f558a470ca 100644 --- a/mod/box/box_lua.m +++ b/mod/box/box_lua.m @@ -656,7 +656,7 @@ static const struct luaL_reg lbox_iterator_meta[] = { + (PortLua *) alloc { size_t sz = class_getInstanceSize(self); - id new = palloc(fiber->gc_pool, sz); + id new = palloca(fiber->gc_pool, sz, sizeof(void *)); object_setClass(new, self); return new; } diff --git a/mod/box/request.m b/mod/box/request.m index 8f2ccdb67e..942fcf2a28 100644 --- a/mod/box/request.m +++ b/mod/box/request.m @@ -939,7 +939,7 @@ do_update_ops(struct update_cmd *cmd, struct tuple *new_tuple) + (Request *) alloc { size_t sz = class_getInstanceSize(self); - id new = palloc(fiber->gc_pool, sz); + id new = palloca(fiber->gc_pool, sz, sizeof(void *)); object_setClass(new, self); return new; } diff --git a/src/exception.m b/src/exception.m index 35f249b944..8a50bbde7a 100644 --- a/src/exception.m +++ b/src/exception.m @@ -42,7 +42,8 @@ if (e != nil && class_getInstanceSize(self) <= sz) { object_setClass(e, self); } else { - object_dispose(e); + if (e != nil) + object_dispose(e); e = class_createInstance(self, 0); sz = class_getInstanceSize(self); } -- GitLab