public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libquadmath/114533] New: libquadmath: printf: fix misaligned access on args
@ 2024-03-30 12:48 doko at gcc dot gnu.org
  2024-04-02 11:29 ` [Bug libquadmath/114533] " rguenth at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: doko at gcc dot gnu.org @ 2024-03-30 12:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114533

            Bug ID: 114533
           Summary: libquadmath: printf: fix misaligned access on args
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libquadmath
          Assignee: unassigned at gcc dot gnu.org
          Reporter: doko at gcc dot gnu.org
  Target Milestone: ---

reported at
https://gcc.gnu.org/pipermail/gcc-patches/2024-March/647635.html

On x86, this compiles into movdqa which segfaults on unaligned access.

This kind of failure has been seen when running against glibc 2.39,
which incidentally changed the printf implementation to move away from
alloca() for this data to instead append it at the end of an existing
"scratch buffer", with arbitrary alignment, whereas alloca() was
probably more likely to be naturally aligned.

Tested by adding the patch to the Ubuntu gcc-14 package in
https://launchpad.net/~schopin/+archive/ubuntu/libquadmath

Signed-off-by: Simon Chopin <simon.chopin@canonical.com>
---
 libquadmath/printf/printf_fp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libquadmath/printf/printf_fp.c b/libquadmath/printf/printf_fp.c
index 8effcee88fa..d86aa650d38 100644
--- a/libquadmath/printf/printf_fp.c
+++ b/libquadmath/printf/printf_fp.c
@@ -363,7 +363,7 @@ __quadmath_printf_fp (struct __quadmath_printf_file *fp,

   /* Fetch the argument value. */
     {
-      fpnum = **(const __float128 **) args[0];
+      memcpy(&fpnum, *(void* const *) args[0], sizeof(fpnum));

       /* Check for special values: not a number or infinity.  */
       if (isnanq (fpnum))

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-04-23  6:45 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-30 12:48 [Bug libquadmath/114533] New: libquadmath: printf: fix misaligned access on args doko at gcc dot gnu.org
2024-04-02 11:29 ` [Bug libquadmath/114533] " rguenth at gcc dot gnu.org
2024-04-02 11:45 ` jakub at gcc dot gnu.org
2024-04-02 12:04 ` schwab@linux-m68k.org
2024-04-02 12:36 ` fw at gcc dot gnu.org
2024-04-02 13:21 ` schwab@linux-m68k.org
2024-04-02 13:41 ` schwab@linux-m68k.org
2024-04-02 17:02 ` jsm28 at gcc dot gnu.org
2024-04-02 17:08 ` jakub at gcc dot gnu.org
2024-04-02 17:30 ` jvdelisle at gcc dot gnu.org
2024-04-02 17:34 ` jakub at gcc dot gnu.org
2024-04-02 18:26 ` doko at gcc dot gnu.org
2024-04-03  8:14 ` cvs-commit at gcc dot gnu.org
2024-04-21  4:08 ` cvs-commit at gcc dot gnu.org
2024-04-23  6:45 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).