From: David Wells Date: Thu, 17 Jun 2021 14:10:33 +0000 (-0400) Subject: Fix a segmentation fault at high optimization levels. X-Git-Tag: v9.3.1~6^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=369a241ad83a3fef560ebd49301d397e0c6e4390;p=dealii.git Fix a segmentation fault at high optimization levels. 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. --- diff --git a/doc/news/changes/minor/20210617DavidWells b/doc/news/changes/minor/20210617DavidWells new file mode 100644 index 0000000000..2948ecdb28 --- /dev/null +++ b/doc/news/changes/minor/20210617DavidWells @@ -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. +
+(David Wells, 2021/06/17) diff --git a/include/deal.II/fe/mapping_q_internal.h b/include/deal.II/fe/mapping_q_internal.h index 4ee907fcfd..cf155f2df9 100644 --- a/include/deal.II/fe/mapping_q_internal.h +++ b/include/deal.II/fe/mapping_q_internal.h @@ -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 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