{"action":"created","issue":{"url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/578","repository_url":"https://api.github.com/repos/MRtrix3/mrtrix3","labels_url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/578/labels{/name}","comments_url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/578/comments","events_url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/578/events","html_url":"https://github.com/MRtrix3/mrtrix3/pull/578","id":151359006,"number":578,"title":"Fix Eigen-related alignment issues ","user":{"login":"jdtournier","id":3221000,"avatar_url":"https://avatars.githubusercontent.com/u/3221000?v=3","gravatar_id":"","url":"https://api.github.com/users/jdtournier","html_url":"https://github.com/jdtournier","followers_url":"https://api.github.com/users/jdtournier/followers","following_url":"https://api.github.com/users/jdtournier/following{/other_user}","gists_url":"https://api.github.com/users/jdtournier/gists{/gist_id}","starred_url":"https://api.github.com/users/jdtournier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdtournier/subscriptions","organizations_url":"https://api.github.com/users/jdtournier/orgs","repos_url":"https://api.github.com/users/jdtournier/repos","events_url":"https://api.github.com/users/jdtournier/events{/privacy}","received_events_url":"https://api.github.com/users/jdtournier/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/MRtrix3/mrtrix3/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-27T11:06:14Z","updated_at":"2016-04-27T11:27:57Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/MRtrix3/mrtrix3/pulls/578","html_url":"https://github.com/MRtrix3/mrtrix3/pull/578","diff_url":"https://github.com/MRtrix3/mrtrix3/pull/578.diff","patch_url":"https://github.com/MRtrix3/mrtrix3/pull/578.patch"},"body":"As originally reported here:\r\nhttp://community.mrtrix.org/t/mrview-segmentationfault-core-dumb-ubuntu-16-04/185\r\n\r\nThe issue is that Eigen expect fixed-sized types to be aligned for vectorised instructions - or rather, SSE/SSE2 expects data to be aligned for these operations. While Eigen does what it can, the standard `operator new()` doesn't provide any alignment guarantees, being type-agnostic. So Eigen provides a macro that is used to add an appropriate `operator new()` member to classes that contain fixed-size Eigen classes such as `Vector3f`, etc. Failing to do this means that dynamic allocation of classes containing fixed-sized Eigen types may fail to align the data properly, and lead to crashes when the classes are subsequently used in vectorised operations. This may not manifest on all hardware, since it depends on the alignment that the default `operator new()` call will use (no problem if it's actually aligning on 16-byte boundaries anyway), and whether the CPU supports SSE4 instructions, which don't require alignment anyway... \r\n\r\nSo this adds the requisite `EIGEN_MAKE_ALIGNED_OPERATOR_NEW` to all classes that I could see that contain a `transform_type` (which is what caused the crash in the original post). I expect there'll be lots more cases cropping up as time goes on, since this will probably affect _all_ `Vector3f`, `Vector4d`, `Matrix3d`, etc. types, which are used extensively in MRtrix3. Thankfully, this is only a problem with _dynamic_ allocation of a class that have one of these as a member... "},"comment":{"url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/comments/215054875","html_url":"https://github.com/MRtrix3/mrtrix3/pull/578#issuecomment-215054875","issue_url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/578","id":215054875,"user":{"login":"jdtournier","id":3221000,"avatar_url":"https://avatars.githubusercontent.com/u/3221000?v=3","gravatar_id":"","url":"https://api.github.com/users/jdtournier","html_url":"https://github.com/jdtournier","followers_url":"https://api.github.com/users/jdtournier/followers","following_url":"https://api.github.com/users/jdtournier/following{/other_user}","gists_url":"https://api.github.com/users/jdtournier/gists{/gist_id}","starred_url":"https://api.github.com/users/jdtournier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdtournier/subscriptions","organizations_url":"https://api.github.com/users/jdtournier/orgs","repos_url":"https://api.github.com/users/jdtournier/repos","events_url":"https://api.github.com/users/jdtournier/events{/privacy}","received_events_url":"https://api.github.com/users/jdtournier/received_events","type":"User","site_admin":false},"created_at":"2016-04-27T11:27:57Z","updated_at":"2016-04-27T11:27:57Z","body":"> Might be worth seeing if the fault can be reproduced using e.g. -mno-sse4 option for gcc. \r\n\r\nGood call. Trying that now..."}}