[Bug 2052929]
Cvs-commit
2052929 at bugs.launchpad.net
Wed Apr 3 08:14:14 UTC 2024
The master branch has been updated by Jakub Jelinek <jakub at gcc.gnu.org>:
https://gcc.gnu.org/g:8455d6f6cd43b7b143ab9ee19437452fceba9cc9
commit r14-9769-g8455d6f6cd43b7b143ab9ee19437452fceba9cc9
Author: Jakub Jelinek <jakub at redhat.com>
Date: Wed Apr 3 10:02:35 2024 +0200
libquadmath: Don't assume the storage for __float128 arguments is aligned [PR114533]
With the register_printf_type/register_printf_modifier/register_printf_specifier
APIs the C library is just told the size of the argument and is provided with
a callback to fetch the argument from va_list using va_arg into C library provided
memory. The C library isn't told what alignment requirement it has, but we were
using direct load of a __float128 value from that memory which assumes
__alignof (__float128) alignment.
The following patch fixes that by using memcpy instead.
I haven't been able to reproduce an actual crash, tried
#include <quadmath.h>
#include <stdlib.h>
#include <stdio.h>
int main ()
{
__float128 r;
int prec = 20;
int width = 46;
char buf[128];
r = 2.0q;
r = sqrtq (r);
int n = quadmath_snprintf (buf, sizeof buf, "%+-#*.20Qe", width, r);
if ((size_t) n < sizeof buf)
printf ("%s\n", buf);
/* Prints: +1.41421356237309504880e+00 */
quadmath_snprintf (buf, sizeof buf, "%Qa", r);
if ((size_t) n < sizeof buf)
printf ("%s\n", buf);
/* Prints: 0x1.6a09e667f3bcc908b2fb1366ea96p+0 */
n = quadmath_snprintf (NULL, 0, "%+-#46.*Qe", prec, r);
if (n > -1)
{
char *str = malloc (n + 1);
if (str)
{
quadmath_snprintf (str, n + 1, "%+-#46.*Qe", prec, r);
printf ("%s\n", str);
/* Prints: +1.41421356237309504880e+00 */
}
free (str);
}
printf ("%+-#*.20Qe\n", width, r);
printf ("%Qa\n", r);
printf ("%+-#46.*Qe\n", prec, r);
printf ("%d %Qe %d %Qe %d %Qe\n", 1, r, 2, r, 3, r);
return 0;
}
In any case, I think memcpy for loading from it is right.
2024-04-03 Simon Chopin <simon.chopin at canonical.com>
Jakub Jelinek <jakub at redhat.com>
PR libquadmath/114533
* printf/printf_fp.c (__quadmath_printf_fp): Use memcpy to copy
__float128 out of args.
* printf/printf_fphex.c (__quadmath_printf_fphex): Likewise.
Signed-off-by: Simon Chopin <simon.chopin at canonical.com>
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to glibc in Ubuntu.
https://bugs.launchpad.net/bugs/2052929
Title:
failed autopkgtests for evolver vs glibc 2.39 on amd64
Status in gcc:
In Progress
Status in evolver package in Ubuntu:
New
Status in gcc-13 package in Ubuntu:
Fix Released
Status in gcc-14 package in Ubuntu:
Fix Released
Status in glibc package in Ubuntu:
Invalid
Status in evolver package in Debian:
New
Bug description:
The autopkgests for evolver fail when run against glibc 2.39 on amd64
with a segfault:
3537s autopkgtest [09:43:29]: test command6: [-----------------------
3537s Surface Evolver Version 2.70a (Debian 2.70+ds-8build1), August 27, 2013, 64-bit.
3537s Compiled for float128, 33 digits precision.
3537s Built with Geomview support.
3537s
3537s Enter command:
3537s Enter command: // Typical evolution to sphere
3537s Enter command: gogo := { g 5; r; g 5; hessian; r; g 5; hessian; }
3537s Enter command:
3537s Enter command: // Evolution to very high accuracy, using higher-order Lagrange elements.
3537s Enter command: // To be run on original datafile.
3537s Enter command: gogo2 := { g 5; r; g 5; hessian; r; g 5; hessian;
3537s more> lagrange 2; g 5; hessian;
3537s more> lagrange 4; g 5; hessian;
3537s more> lagrange 6; g 5; hessian;
3537s more> ideal_rad := (3*body[1].volume/4/pi)^(1/3);
3537s more> printf "Area error: %g\n",total_area - 4*pi*ideal_rad^2;
3537s more> printf "Vertex radius spread: %g\n",
3537s more> max(vertex,sqrt((x-.5)^2+(y-.5)^2+(z-.5)^2))
3537s more> - min(vertex,sqrt((x-.5)^2+(y-.5)^2+(z-.5)^2));
3537s more> }
3537s Enter command: g 5; v; r ; g 10; v;
3537s bash: line 1: 1012 Done echo "g 5; v; r ; g 10; v;"
3537s 1013 Segmentation fault (core dumped) | evolver-nox-q cube
To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc/+bug/2052929/+subscriptions
More information about the foundations-bugs
mailing list