Skip to content

Commit 15ebd92

Browse files
committed
Solving more CIs towards new version.
1 parent 061064c commit 15ebd92

6 files changed

Lines changed: 52 additions & 18 deletions

File tree

cmake/InstallGBench.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
if(NOT GBENCH_FOUND OR USE_BUNDLED_GBENCH)
2626
if(NOT GBENCH_VERSION OR USE_BUNDLED_GBENCH)
27-
set(GBENCH_VERSION 1.6.1)
27+
set(GBENCH_VERSION 1.9.5)
2828
endif()
2929

3030
include(FetchContent)

source/adt/source/adt_set_small.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ int set_small_insert(set_small s, const char *key, void *value)
126126
{
127127
union set_small_key_type set_key = { 0 };
128128
set_small_element element = NULL;
129+
size_t key_size = 0;
129130

130131
if (s == NULL || key == NULL || value == NULL)
131132
{
@@ -134,7 +135,8 @@ int set_small_insert(set_small s, const char *key, void *value)
134135
}
135136

136137
/* Copy string into key with last bytes set to 0 */
137-
strncpy(set_key.string, key, SET_SMALL_KEY_SIZE);
138+
key_size = strnlen(key, SET_SMALL_KEY_SIZE);
139+
memcpy(set_key.string, key, key_size);
138140

139141
/* Find if the element already exists */
140142
element = set_small_find(s, set_key);
@@ -157,6 +159,7 @@ void *set_small_get(set_small s, const char *key)
157159
{
158160
union set_small_key_type set_key = { 0 };
159161
set_small_element element = NULL;
162+
size_t key_size = 0;
160163

161164
if (s == NULL || key == NULL)
162165
{
@@ -165,7 +168,8 @@ void *set_small_get(set_small s, const char *key)
165168
}
166169

167170
/* Copy string into key with last bytes set to 0 */
168-
strncpy(set_key.string, key, SET_SMALL_KEY_SIZE);
171+
key_size = strnlen(key, SET_SMALL_KEY_SIZE);
172+
memcpy(set_key.string, key, key_size);
169173

170174
/* Find if the element already exists */
171175
element = set_small_find(s, set_key);
@@ -182,6 +186,7 @@ void *set_small_remove(set_small s, const char *key)
182186
{
183187
union set_small_key_type set_key = { 0 };
184188
size_t iterator = 0;
189+
size_t key_size = 0;
185190

186191
if (s == NULL || key == NULL)
187192
{
@@ -190,7 +195,8 @@ void *set_small_remove(set_small s, const char *key)
190195
}
191196

192197
/* Copy string into key with last bytes set to 0 */
193-
strncpy(set_key.string, key, SET_SMALL_KEY_SIZE);
198+
key_size = strnlen(key, SET_SMALL_KEY_SIZE);
199+
memcpy(set_key.string, key, key_size);
194200

195201
/* Find the element and remove it */
196202
for (iterator = 0; iterator < s->size; ++iterator)

source/loaders/c_loader/source/c_loader_impl.cpp

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -989,15 +989,38 @@ function_return function_c_interface_invoke(function func, function_impl impl, f
989989
/* We can accept pointers if we pass to an array and null to a pointer or array, it is unsafe but it improves efficiency */
990990
if (id != value_id && !(value_id == TYPE_PTR && id == TYPE_ARRAY) && !(value_id == TYPE_NULL && id == TYPE_PTR) && !(value_id == TYPE_NULL && id == TYPE_ARRAY))
991991
{
992-
return metacall::metacall_error_throw("C Loader Error", 0, "",
993-
"Type mismatch in when calling %s in argument number %" PRIuS
994-
" (expected %s of type %s and received %s)."
995-
" Canceling call in order to avoid a segfault.",
996-
function_name(func),
997-
args_count,
998-
type_name(t),
999-
type_id_name(id),
1000-
type_id_name(value_id));
992+
/* We can do type casting on integers and floats for scripting languages or solving multi-platform issues */
993+
if ((type_id_integer(value_id) == 0 && type_id_integer(id) == 0) || (type_id_integer(value_id) == 0 && type_id_decimal(id) == 0) || (type_id_decimal(value_id) == 0 && type_id_integer(id) == 0) || (type_id_decimal(value_id) == 0 && type_id_decimal(id) == 0))
994+
{
995+
value cast_result = value_type_cast(args[args_count], id);
996+
997+
if (cast_result == NULL)
998+
{
999+
return metacall::metacall_error_throw("C Loader Error", 0, "",
1000+
"Invalid type casting when calling %s in argument number %" PRIuS
1001+
" (expected %s of type %s and received %s)."
1002+
" Canceling call in order to avoid a segfault.",
1003+
function_name(func),
1004+
args_count,
1005+
type_name(t),
1006+
type_id_name(id),
1007+
type_id_name(value_id));
1008+
}
1009+
1010+
args[args_count] = cast_result;
1011+
}
1012+
else
1013+
{
1014+
return metacall::metacall_error_throw("C Loader Error", 0, "",
1015+
"Type mismatch in when calling %s in argument number %" PRIuS
1016+
" (expected %s of type %s and received %s)."
1017+
" Canceling call in order to avoid a segfault.",
1018+
function_name(func),
1019+
args_count,
1020+
type_name(t),
1021+
type_id_name(id),
1022+
type_id_name(value_id));
1023+
}
10011024
}
10021025

10031026
if (value_id == TYPE_FUNCTION)

source/loaders/rb_loader/include/rb_loader/rb_loader_include.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#if defined(__clang__)
3030
#pragma clang diagnostic push
3131
#pragma clang diagnostic ignored "-Wunused-parameter"
32+
#pragma clang diagnostic ignored "-Wc23-extensions"
3233
#elif defined(__GNUC__)
3334
#pragma GCC diagnostic push
3435
#pragma GCC diagnostic ignored "-Wredundant-decls"

source/tests/metacall_python_port_c_lib_metacall_test/source/metacall_python_port_c_lib_metacall_test.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,20 @@ TEST_F(metacall_python_port_c_lib_metacall_test, DefaultConstructor)
4747
" 'libs': ['" METACALL_LIBRARY "']\n"
4848
"})\n"
4949
/* Print all MetaCall APIs (metacall_lib is a dict subclass; use key iteration, not dir) */
50-
"print([k for k in metacall_lib.keys() if k.startswith('metacall')])\n"
50+
"print([k for k in metacall_lib.keys() if k.startswith('metacall')], flush=True)\n"
5151
/* Print info */
5252
"metacall_lib['metacall_print_info']()\n"
5353
/* MetaCall Load from Memory */
5454
"script = 'module.exports = { metacircular: () => 46 }'\n"
55-
"assert metacall_lib['metacall_load_from_memory']('node', script, len(script) + 1, None) == 0, 'metacall load from memory failed'\n"
55+
"metacall_load_from_memory = metacall_lib['metacall_load_from_memory']\n"
56+
"print(metacall_load_from_memory, flush=True)\n"
57+
"load_from_mem_result = metacall_load_from_memory('node', script, len(script) + 1, None)\n"
58+
"print(load_from_mem_result, flush=True)\n"
59+
"assert load_from_mem_result == 0, 'metacall load from memory failed'\n"
5660
"result = metacall_lib['metacall']('metacircular')\n"
57-
"print(result)\n"
61+
"print(result, flush=True)\n"
5862
"metacircular = metacall_lib['metacall_value_to_double'](result)\n"
59-
"print(metacircular)\n"
63+
"print(metacircular, flush=True)\n"
6064
"assert metacircular == 46, 'metacircular must be 46, invoke failed'\n"
6165
"\n";
6266

tools/metacall-environment.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ sub_python(){
208208
# PYTHON_EXE="${PYTHON_PKG}t"
209209
PYTHON_EXE="${PYTHON_PKG}"
210210
elif [ $INSTALL_MEMORY_SANITIZER = 1 ]; then
211-
export MSAN_OPTIONS="halt_on_error=0:use_sigaltstack=0"
211+
export MSAN_OPTIONS="halt_on_error=0:use_sigaltstack=0:poison_in_dtor=0"
212212
BUILD_FLAGS="--with-memory-sanitizer --with-pydebug"
213213
BUILD_LDFLAGS="-fsanitize=memory"
214214
fi

0 commit comments

Comments
 (0)