]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix a segmentation fault at high optimization levels. 12518/head
authorDavid Wells <drwells@email.unc.edu>
Thu, 17 Jun 2021 14:10:33 +0000 (10:10 -0400)
committerDavid Wells <drwells@email.unc.edu>
Mon, 28 Jun 2021 19:47:27 +0000 (15:47 -0400)
I don't completely understand this but accessing these pointers causes
segmentation faults. It's not due to type aliasing - converting both to 'const
auto *' does not fix the problem.

doc/news/changes/minor/20210617DavidWells [new file with mode: 0644]
include/deal.II/fe/mapping_q_internal.h
source/fe/mapping_fe.cc

diff --git a/doc/news/changes/minor/20210617DavidWells b/doc/news/changes/minor/20210617DavidWells
new file mode 100644 (file)
index 0000000..2948ecd
--- /dev/null
@@ -0,0 +1,5 @@
+Fixed: Removed some pointers in MappingQGeneric and MappingFE that could cause
+segmentation faults at high optimization levels due to compiler assumptions
+about data alignment.
+<br>
+(David Wells, 2021/06/17)
index 4ee907fcfde28f73362c7ffc152b5c6fcb843d31..cf155f2df92196fdffdf6743522aeace4895ebca 100644 (file)
@@ -1308,25 +1308,21 @@ namespace internal
 
             Assert(data.n_shape_functions > 0, ExcInternalError());
 
-            const Tensor<1, spacedim> *supp_pts =
-              data.mapping_support_points.data();
-
             for (unsigned int point = 0; point < n_q_points; ++point)
               {
-                const Tensor<1, dim> *data_derv =
-                  &data.derivative(point + data_set, 0);
-
                 double result[spacedim][dim];
 
                 // peel away part of sum to avoid zeroing the
                 // entries and adding for the first time
                 for (unsigned int i = 0; i < spacedim; ++i)
                   for (unsigned int j = 0; j < dim; ++j)
-                    result[i][j] = data_derv[0][j] * supp_pts[0][i];
+                    result[i][j] = data.derivative(point + data_set, 0)[j] *
+                                   data.mapping_support_points[0][i];
                 for (unsigned int k = 1; k < data.n_shape_functions; ++k)
                   for (unsigned int i = 0; i < spacedim; ++i)
                     for (unsigned int j = 0; j < dim; ++j)
-                      result[i][j] += data_derv[k][j] * supp_pts[k][i];
+                      result[i][j] += data.derivative(point + data_set, k)[j] *
+                                      data.mapping_support_points[k][i];
 
                 // write result into contravariant data. for
                 // j=dim in the case dim<spacedim, there will
index 7148b36811b36fd95cff5ace89c06cd9793ed25c..9362d01ae68c472403baad733781ffa6e157d62b 100644 (file)
@@ -329,25 +329,22 @@ namespace internal
 
               Assert(data.n_shape_functions > 0, ExcInternalError());
 
-              const Tensor<1, spacedim> *supp_pts =
-                data.mapping_support_points.data();
-
               for (unsigned int point = 0; point < n_q_points; ++point)
                 {
-                  const Tensor<1, dim> *data_derv =
-                    &data.derivative(point + data_set, 0);
-
                   double result[spacedim][dim];
 
                   // peel away part of sum to avoid zeroing the
                   // entries and adding for the first time
                   for (unsigned int i = 0; i < spacedim; ++i)
                     for (unsigned int j = 0; j < dim; ++j)
-                      result[i][j] = data_derv[0][j] * supp_pts[0][i];
+                      result[i][j] = data.derivative(point + data_set, 0)[j] *
+                                     data.mapping_support_points[0][i];
                   for (unsigned int k = 1; k < data.n_shape_functions; ++k)
                     for (unsigned int i = 0; i < spacedim; ++i)
                       for (unsigned int j = 0; j < dim; ++j)
-                        result[i][j] += data_derv[k][j] * supp_pts[k][i];
+                        result[i][j] +=
+                          data.derivative(point + data_set, k)[j] *
+                          data.mapping_support_points[k][i];
 
                   // write result into contravariant data. for
                   // j=dim in the case dim<spacedim, there will

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.