-
Bug
-
Resolution: Done
-
Medium
-
El Alto Release
-
None
The evel_new_xxxx() crashes if call them in thread.
for example:
#include <stdio.h> #include <pthread.h> #include <string.h> void* thread_run(void* _val) { EVENT_FAULT* fault = evel_new_fault(....); evel_free_event(fault); return; } int main() { pthread_t tid; int tret = pthread_create(&tid, NULL, thread_run, "thread_run~~~~~"); int ret = pthread_join(tid, NULL); return 0; }
Root cause:
There are some C code written with C99 as below, they cause build errors " error: ‘for’ loop initial declarations are only allowed in C99 mode".
for(unsigned int idx = 0; idx < ht->size; idx++ )
To fix this error, user need to build the library with -std=c99.
In the library, strdup() is used to malloc/copy string. The strdup() is not provided by ISO C , but POSIX. So when defining -std=c99, the strdup() declaration become invisible. Under C99 rules, calling a function with no visible declaration is a constraint violation.
The easiest solution is make the for loop as below, so as to avoid C99 mode.
unsigned int idx = 0; for(; idx < ht->size; idx++ )