Hi,

in the function MurmurHash3::put an unaligned access fault happens on an arm 
system.
The linux kernel is able to emulate the unaligned LDM instruction, but it is 
still not
desirable, to generate code that depends on that.


Fixed by the attached patch.

Bootstrapped and reg-tested on arm-linux-gnueabihf
Is it OK for trunk?


Thanks
Bernd.
2019-02-08  Bernd Edlinger  <bernd.edlin...@hotmail.de>

	PR d/89177
	* src/std/digest/murmurhash.d (MurmurHash3::put): Avoid unaligned
	access traps.

Index: libphobos/src/std/digest/murmurhash.d
===================================================================
--- libphobos/src/std/digest/murmurhash.d	(revision 268614)
+++ libphobos/src/std/digest/murmurhash.d	(working copy)
@@ -516,9 +516,11 @@ struct MurmurHash3(uint size /* 32 or 128 */ , uin
         // Do main work: process chunks of `Element.sizeof` bytes.
         const numElements = data.length / Element.sizeof;
         const remainderStart = numElements * Element.sizeof;
-        foreach (ref const Element block; cast(const(Element[]))(data[0 .. remainderStart]))
+        for (auto start = 0; start < remainderStart; start += Element.sizeof)
         {
-            putElement(block);
+            BufferUnion buffer;
+            buffer.data[0 .. $] = data[start .. start + Element.sizeof];
+            putElement(buffer.block);
         }
         // +1 for bufferLeeway Element.
         element_count += (numElements + 1) * Element.sizeof;

Reply via email to