fix: correct valgrind errors

main
Sean McBride 4 years ago
parent 0892e98d76
commit eca987ccb4

@ -4,6 +4,7 @@
#include "types.h" #include "types.h"
extern int runtime_epoll_file_descriptor; extern int runtime_epoll_file_descriptor;
extern u32 runtime_total_worker_processors;
void alloc_linear_memory(void); void alloc_linear_memory(void);
void expand_memory(void); void expand_memory(void);

@ -84,12 +84,14 @@ runtime_allocate_available_cores()
runtime_total_worker_processors = max_possible_workers; runtime_total_worker_processors = max_possible_workers;
if (max_possible_workers >= WORKER_THREAD_CORE_COUNT) if (max_possible_workers >= WORKER_THREAD_CORE_COUNT)
runtime_total_worker_processors = WORKER_THREAD_CORE_COUNT; runtime_total_worker_processors = WORKER_THREAD_CORE_COUNT;
assert(runtime_total_worker_processors == WORKER_THREAD_CORE_COUNT);
} else { } else {
/* If single core, we'll do everything on CPUID 0 */ /* If single core, we'll do everything on CPUID 0 */
runtime_first_worker_processor = 0; runtime_first_worker_processor = 0;
runtime_total_worker_processors = 1; runtime_total_worker_processors = 1;
} }
debuglog("Number of cores %u, sandboxing cores %u (start: %u) and module reqs %u\n", printf("Number of cores %u, sandboxing cores %u (start: %u) and module reqs %u\n",
runtime_total_online_processors, runtime_total_worker_processors, runtime_first_worker_processor, runtime_total_online_processors, runtime_total_worker_processors, runtime_first_worker_processor,
LISTENER_THREAD_CORE_ID); LISTENER_THREAD_CORE_ID);
} }

@ -257,8 +257,7 @@ module_new_from_json(char *file_name)
fprintf(stderr, "Attempt to read %s into buffer failed: %s\n", file_name, strerror(errno)); fprintf(stderr, "Attempt to read %s into buffer failed: %s\n", file_name, strerror(errno));
goto fread_err; goto fread_err;
} }
assert(total_chars_read > 0);
assert(strlen(file_buffer) > 1);
/* Close the file */ /* Close the file */
errno = 0; errno = 0;
@ -274,7 +273,7 @@ module_new_from_json(char *file_name)
jsmntok_t tokens[JSON_MAX_ELEMENT_SIZE * JSON_MAX_ELEMENT_COUNT]; jsmntok_t tokens[JSON_MAX_ELEMENT_SIZE * JSON_MAX_ELEMENT_COUNT];
/* Use Jasmine to parse the JSON */ /* Use Jasmine to parse the JSON */
int total_tokens = jsmn_parse(&module_parser, file_buffer, strlen(file_buffer), tokens, int total_tokens = jsmn_parse(&module_parser, file_buffer, total_chars_read, tokens,
sizeof(tokens) / sizeof(tokens[0])); sizeof(tokens) / sizeof(tokens[0]));
if (total_tokens < 0) { if (total_tokens < 0) {
if (total_tokens == JSMN_ERROR_INVAL) { if (total_tokens == JSMN_ERROR_INVAL) {

@ -11,6 +11,7 @@
#include "current_sandbox.h" #include "current_sandbox.h"
#include "local_runqueue.h" #include "local_runqueue.h"
#include "module.h" #include "module.h"
#include "runtime.h"
#include "sandbox.h" #include "sandbox.h"
#include "software_interrupt.h" #include "software_interrupt.h"
#include "types.h" #include "types.h"
@ -66,10 +67,11 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void
/* A POSIX signal is delivered to one of the threads in our process.If sent by the kernel, "broadcast" /* A POSIX signal is delivered to one of the threads in our process.If sent by the kernel, "broadcast"
* by forwarding to all all threads */ * by forwarding to all all threads */
if (signal_info->si_code == SI_KERNEL) { if (signal_info->si_code == SI_KERNEL) {
for (int i = 0; i < WORKER_THREAD_CORE_COUNT; i++) { for (int i = 0; i < runtime_total_worker_processors; i++) {
if (pthread_self() == runtime_worker_threads[i]) continue; if (pthread_self() != runtime_worker_threads[i]) {
pthread_kill(runtime_worker_threads[i], SIGALRM); pthread_kill(runtime_worker_threads[i], SIGALRM);
} }
}
} else { } else {
/* If not sent by the kernel, this should be a signal forwarded from another thread */ /* If not sent by the kernel, this should be a signal forwarded from another thread */
assert(signal_info->si_code == SI_TKILL); assert(signal_info->si_code == SI_TKILL);

Loading…
Cancel
Save