hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Colin Patrick McCabe (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-11638) Linux-specific gettid() used in OpensslSecureRandom.c
Date Fri, 06 Mar 2015 20:43:39 GMT

    [ https://issues.apache.org/jira/browse/HADOOP-11638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14350862#comment-14350862
] 

Colin Patrick McCabe commented on HADOOP-11638:
-----------------------------------------------

bq. Casting the return value of pthread_getthreadid_np may be lossy. FreeBSD uses an unsigned
long for thread IDs, but that function casts it to an int.

Did you look at the wrong patch?  The function doesn't cast anything to an int.

{code}
 static unsigned long pthreads_thread_id(void)
 {
-  return (unsigned long)syscall(SYS_gettid);
+  unsigned long thread_id = 0;
+#if defined(__linux__)
+  thread_id = (unsigned long)syscall(SYS_gettid);
+#elif defined(__FreeBSD__)
+  thread_id = (unsigned long)pthread_getthreadid_np();
+#elif defined(__sun)
+  thread_id = (unsigned long)pthread_self();
+#else
+#error "Platform not supported"
+#endif
+  return thread_id;
 }
{code}

also, FreeBSD's pthread_getthreadid_np returns an int, not an unsigned long.  http://www.freebsd.org/cgi/man.cgi?query=pthread_getthreadid_np&sektion=3&apropos=0&manpath=FreeBSD%2B10.0-RELEASE

+1 for 003.  Let's commit this.

> Linux-specific gettid() used in OpensslSecureRandom.c
> -----------------------------------------------------
>
>                 Key: HADOOP-11638
>                 URL: https://issues.apache.org/jira/browse/HADOOP-11638
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: native
>    Affects Versions: 2.6.0
>            Reporter: Dmitry Sivachenko
>            Assignee: Kiran Kumar M R
>              Labels: freebsd
>         Attachments: HADOOP-11638-001.patch, HADOOP-11638-002.patch, HADOOP-11638-003.patch
>
>
> In OpensslSecureRandom.c you use Linux-specific syscall gettid():
> static unsigned long pthreads_thread_id(void)
> {
> return (unsigned long)syscall(SYS_gettid);
> }
> Man page says:
> gettid()  is Linux-specific and should not be used in programs that are
> intended to be portable.
> This breaks hadoop-2.6.0 compilation on FreeBSD (may be on other OSes too).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message