Hi,

On Sun, Dec 18, 2016 at 5:04 AM, Mike Williams
<[email protected]> wrote:
> On 14/12/2016 08:44, Dominique Pellé wrote:
>>
>> Yegappan Lakshmanan wrote:
>>>
>>> When running the Vim tests with UBSan, the following errors are
>>> reported:
>>>
>>> channel.c:713:5: runtime error: load of misaligned address
>>> 0x60b0000069ca for type 'char *', which requires 8 byte alignment
>>> 0x60b0000069ca: note: pointer points here
>>
>>
>> Line 713 is is this for me:
>>
>>  713     memcpy((char *)&server.sin_addr, host->h_addr, host->h_length);
>>
>> I don't see this error with ubsan. A char* should not require 8 byte
>> alignment anyway. Strange.
>
>
> This is a strange one.  I would guess at a compiler issue.  Stack overflow
> coughs up these somewhat related issues on OSX which I think you are using:
>
> http://stackoverflow.com/questions/18821491/how-to-fix-unaligned-pointer-char#18822141
> http://stackoverflow.com/questions/19916762/how-to-fix-unaligned-pointer-char?noredirect=1&lq=1
>
> h_addr is usually a macro to h_addr_list[0] where h_addr_list is a char**.
> If you aren't seeing a problem it may be a false positive.
>

The attached patch fixes this runtime error. But I am not sure whether
this is worth fixing it or not.

- Yegappan

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/channel.c b/src/channel.c
index 32f3527..627b9e8 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -678,6 +678,7 @@ channel_open(
     int                        sd = -1;
     struct sockaddr_in server;
     struct hostent     *host;
+    char               *p;
 #ifdef WIN32
     u_short            port = port_in;
     u_long             val = 1;
@@ -710,7 +711,8 @@ channel_open(
        channel_free(channel);
        return NULL;
     }
-    memcpy((char *)&server.sin_addr, host->h_addr, host->h_length);
+    memcpy(&p, &host->h_addr, sizeof(host->h_addr));
+    memcpy((char *)&server.sin_addr, p, host->h_length);
 
     /* On Mac and Solaris a zero timeout almost never works.  At least wait
      * one millisecond. Let's do it for all systems, because we don't know why

Raspunde prin e-mail lui