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

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

bq. I had to revert the prior committed patch, because it actually broke 
compilation for Mac. That's why I reopened this issue and asked for a corrected 
patch.

I'm very surprised that it compiled on Mac earlier.  It was using system calls 
which we believed were Linux-specific.

{code}
288     #elif defined(__APPLE__)
289       (void)pthread_threadid_np(pthread_self(), &thread_id);
{code}

I looked at this and found that {{pthread_threadid_np}} on Mac has the type 
signature: {{int pthread_threadid_np(pthread_t thread, __uint64_t *thread_id)}} 
 This doesn't match with using an {{unsigned long}}.  I'm not sure under what 
conditions an {{unsigned long}} is different than a {{uint64_t}} on Mac (on 
Linux, that would be the case with 32-bit compilation).  So this patch may have 
a buffer overflow in that case.

Should we file a follow-on to fix this?  Simplest fix is just using a temporary 
variable of type {{uint64_t}} and copying that into the {{unsigned long}}.  
It's not a perfect solution since two threads may get the same ID in 32-bit 
land ( you can blame openssl's boneheaded use of a long here instead of a 
uint64_t) but it's sure better than a buffer overflow.

> OpensslSecureRandom.c pthreads_thread_id should support FreeBSD and Solaris 
> in addition to Linux
> ------------------------------------------------------------------------------------------------
>
>                 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
>             Fix For: 2.7.0
>
>         Attachments: HADOOP-11638-001.patch, HADOOP-11638-002.patch, 
> HADOOP-11638-003.patch, HADOOP-11638-004.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)

Reply via email to