Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One of the reasons the crash might occur on x86 is due to alignment issues. I do not have clang on my system to reproduce the problem, but I can demonstrate it at the example of GCC.</p> <p>If you do something like:</p> <pre><code>/* Define a vector type of 16 characters. */ typedef char __attribute__ ((vector_size (16))) byte16; /* Global pointer. */ char * foo; byte16 test () { return *(byte16 *)&amp;foo[1]; } </code></pre> <p>Now if you compile it on a vector-capable x86 with:</p> <pre><code>$ gcc -O3 -march=native -mtune=native a.c </code></pre> <p>You will get the following assembly for test:</p> <pre><code>test: movq foo(%rip), %rax vmovdqa 1(%rax), %xmm0 ret </code></pre> <p>Please note, that the move is aligned, which is of course wrong. Now, if you would inline this function into the main, and you will have something like:</p> <pre><code>int main () { foo = __builtin_malloc (22); byte16 x = *(byte16 *)&amp;foo[1]; return x[0]; } </code></pre> <p>You will be fine, and you will get unaligned instruction. This is kind of a bug, which doesn't have a very good fix in the compiler, as it would require interprocedural optimisations with addition of new data structures, etc.</p> <p>The origin of the problem is that the compiler assumes that vector types are aligned, so when you dereference an array of aligned vector types you can use an aligned move. As a workaround for the problem in GCC one can define an unaligned vector type like:</p> <pre><code>typedef char __attribute__ ((vector_size (16),aligned (1))) unaligned_byte16; </code></pre> <p>And use it to dereference unaligned memory.</p> <p>I am not sure that you are hitting exactly this problem within your setup, but this is something that I would recommend to check by inspecting the assembly output from your compiler.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload