DescriptionThere are C library functions including some
standardised by POSIX that require setting errno to
zero and examining it after calling the function in
question to differentiate between errors and other
conditions.
An example is getpwuid(), where to tell the difference
between a user-id for which there is no information
and an error, the standard says this:
http://www.opengroup.org/onlinepubs/7990989775/xsh/getpwuid.html
"Applications wishing to check for error
situations should set errno to 0 before
calling getpwuid(). If getpwuid() returns a
null pointer and errno is set to non-zero, an
error occurred."
It can be argued that library functions should not use
errno (a position I agree with) but it can also be
argued that it's too late now, particularly for
functions specified by standards and functions from
third party libraries for which a developer may not
have the source.
There has been a thread discussing this issue on the golang-nuts
mailing list:
http://groups.google.com/group/golang-nuts/browse_thread/thread/5ef21e2af40a03e
From that thread, the most succinct comment was made by Russ Cox:
"C makes it safe by making errno a thread-local variable
in a threaded program.
"Cgo can easily, and should, make it equally safe."
I'm opening this issue so that the discussion is not
lost, and in the hope that at some future time I or
someone else will be able to address it.
ight now I don't know what code changess are needed.
As the issue tracker requires a diff, I have settled
for a diff that adds a TODO to src/cmd/cgo/main.go,
which I cheerfully admit is a cop-out!
[ Edit: found what I should have done, and have now opened issue 709 http://code.google.com/p/go/issues/detail?id=709&colspec=ID%20Priority%20Status%20Owner%20Reporter%20Summary and referenced this CL. ]
Patch Set 1 #
MessagesTotal messages: 1
|
|||||||||||||||||||