davidsch / rpms / bout++

Forked from rpms/bout++ 2 years ago
Clone

Blame arm-deref.patch

David Schwörer 86b481b
commit 97418106eb7cf1f6dd660b494939af83b88beda6
David Schwörer 86b481b
Author: David Schwörer <schword2@mail.dcu.ie>
David Schwörer 86b481b
Date:   Mon Nov 25 13:18:33 2019 +0000
David Schwörer 86b481b
David Schwörer 86b481b
    Address needs to be aligned
David Schwörer 86b481b
    
David Schwörer 86b481b
    This value gets dereferenced by python, but without knowing it's true
David Schwörer 86b481b
    type. Thus a SIGBUS is thrown on some architectures, namely arm. This
David Schwörer 86b481b
    can be avoided by copying it to a larger type first, e.g. long, that
David Schwörer 86b481b
    is sufficiently aligned, and thus can be safely dereferenced by
David Schwörer 86b481b
    python.
David Schwörer 86b481b
David Schwörer 86b481b
diff --git a/tools/pylib/_boutcore_build/helper.h.in b/tools/pylib/_boutcore_build/helper.h.in
David Schwörer 86b481b
index 24c26bdf0..21f264d4c 100644
David Schwörer 86b481b
--- a/tools/pylib/_boutcore_build/helper.h.in
David Schwörer 86b481b
+++ b/tools/pylib/_boutcore_build/helper.h.in
David Schwörer 86b481b
@@ -77,8 +77,9 @@ class PythonModelCallback{
David Schwörer 86b481b
 class PythonModel: public PhysicsModel{
David Schwörer 86b481b
 protected:
David Schwörer 86b481b
   int init(bool restarting) override{
David Schwörer 86b481b
+    long aligned_restarting = restarting;
David Schwörer 86b481b
     if (_init){
David Schwörer 86b481b
-      _init->cy_execute(&restarting);
David Schwörer 86b481b
+      _init->cy_execute(&aligned_restarting);
David Schwörer 86b481b
     }
David Schwörer 86b481b
     return 0;
David Schwörer 86b481b
   };