runtimeverification / rv-predict

Code for improved rv-predict and installer
BSD 3-Clause "New" or "Revised" License
2 stars 3 forks source link

errno is non-zero at program startup #1031

Closed maya-rv closed 5 years ago

maya-rv commented 5 years ago
#include <errno.h>
int main() {
    return errno;
}

$ rvpc test.c -o test; ./test; echo $?
-- Window 1 --
-- Window 2 --
No races found.
22

I suspect this isn't proper legal, because we make no function call here.

The value of errno in the initial thread is zero at program startup (the initial value of
errno in other threads is an indeterminate value), but is never set to zero by any library
function.202) The value of errno may be set to nonzero by a library function call
whether or not there is an error, provided the use of errno is not documented in the
description of the function in this International Standard.

affects tsan as well.

maya-rv commented 5 years ago

that said, the code that was relying on errno being zero at startup was probably misusing errno.

maya-rv commented 5 years ago

fixed with #1031