work around portability issue on FreeBSD, in which the key returned from

pthread_key_create can be 0.
addresses issue #19567.