How to automate checking if a library of C functions matches repetition?

Given the C function library, is there a way to automate checking if the exported functions are reentrant?

Either at runtime (after tools, if necessary), or from code analysis. Source code is available.

Note. This is not a std-C lib, nor a well-documented GNU lib with a thread safety contract.

+4
source share
1 answer

A function is not considered "thread safe" if it CANNOT be interrupted in the middle of its execution and then safely called again ("re-entered") before its previous calls are completed.

In the C standard library, some functions fall into this category. You don't need a tool like Valgrind to check thread safety, instead you should read the documentation (or the man page) for the specific function you're worried about.

Usually, but not always, C offers a reliable copy of the stream if the function is not stream safe.

For example, the string token function strtokhas a re-versionstrtok_r

char *strtok(char *str, const char *delim);
char *strtok_r(char *str, const char *delim, char **saveptr);

, () ( ) , . strtok_r .

, SO, Threadsafe vs re-entrant.

-

: . , , , . , ltrace, . , , C. .

Valgrind , Helgrind, (. http://valgrind.org/docs/manual/hg-manual.html, 7.1)

+4

Source: https://habr.com/ru/post/1527603/


All Articles