Fix warnings/issues reported in Windows and by CodeQL/Coverity (#3275)

Fix the warnings and issues reported:
- in Windows platform
- by CodeQL static code analyzing
- by Coverity static code analyzing

And update CodeQL script to build exception handling and memory features.
This commit is contained in:
Wenyong Huang
2024-04-07 11:57:31 +08:00
committed by GitHub
parent 53f0941ffa
commit 2013f1f7d7
26 changed files with 202 additions and 118 deletions

View File

@ -785,8 +785,8 @@ gc_alloc_wo_internal(void *vheap, gc_size_t size, const char *file, int line)
if (!hmu)
goto finish;
/* Do we need to memset the memory to 0? */
/* memset((char *)hmu + sizeof(*hmu), 0, tot_size - sizeof(*hmu)); */
/* Don't memset the memory to improve performance, the caller should
decide whether to memset it or not */
bh_assert(hmu_get_size(hmu) >= tot_size);
/* the total size allocated may be larger than

View File

@ -114,8 +114,8 @@ sweep_instance_heap(gc_heap_t *heap)
else {
/* current block is still live */
if (last) {
tot_free += (char *)cur - (char *)last;
gci_add_fc(heap, last, (char *)cur - (char *)last);
tot_free += (gc_size_t)((char *)cur - (char *)last);
gci_add_fc(heap, last, (gc_size_t)((char *)cur - (char *)last));
hmu_mark_pinuse(last);
last = NULL;
}
@ -132,8 +132,8 @@ sweep_instance_heap(gc_heap_t *heap)
bh_assert(cur == end);
if (last) {
tot_free += (char *)cur - (char *)last;
gci_add_fc(heap, last, (char *)cur - (char *)last);
tot_free += (gc_size_t)((char *)cur - (char *)last);
gci_add_fc(heap, last, (gc_size_t)((char *)cur - (char *)last));
hmu_mark_pinuse(last);
}
@ -449,7 +449,9 @@ gci_gc_heap(void *h)
LOG_VERBOSE("#reclaim instance heap %p", heap);
gct_vm_gc_prepare();
/* TODO: get exec_env of current thread when GC multi-threading
is enabled, and pass it to runtime */
gct_vm_gc_prepare(NULL);
gct_vm_mutex_lock(&heap->lock);
heap->is_doing_reclaim = 1;
@ -459,7 +461,9 @@ gci_gc_heap(void *h)
heap->is_doing_reclaim = 0;
gct_vm_mutex_unlock(&heap->lock);
gct_vm_gc_finished();
/* TODO: get exec_env of current thread when GC multi-threading
is enabled, and pass it to runtime */
gct_vm_gc_finished(NULL);
LOG_VERBOSE("#reclaim instance heap %p done", heap);

View File

@ -77,13 +77,13 @@ mem_allocator_free_with_gc(mem_allocator_t allocator, void *ptr)
void
mem_allocator_enable_gc_reclaim(mem_allocator_t allocator, void *exec_env)
{
return gc_enable_gc_reclaim((gc_handle_t)allocator, exec_env);
gc_enable_gc_reclaim((gc_handle_t)allocator, exec_env);
}
#else
void
mem_allocator_enable_gc_reclaim(mem_allocator_t allocator, void *cluster)
{
return gc_enable_gc_reclaim((gc_handle_t)allocator, cluster);
gc_enable_gc_reclaim((gc_handle_t)allocator, cluster);
}
#endif