https://bugs.kde.org/show_bug.cgi?id=474339

            Bug ID: 474339
           Summary: aligned_alloc with alignment less than
                    VG_MIN_MALLOC_SZB causes Valgrind to panic
    Classification: Developer tools
           Product: valgrind
           Version: unspecified
          Platform: Archlinux
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: memcheck
          Assignee: jsew...@acm.org
          Reporter: smj...@gmail.com
  Target Milestone: ---

SUMMARY

This is somewhat connected to https://bugs.kde.org/show_bug.cgi?id=474332,
because if I do a workaround for this here:
https://sourceware.org/git/?p=valgrind.git;a=blob;f=coregrind/m_mallocfree.c;h=44beb3d8b57cc3d7859a2966b4f5824e255fb6d4;hb=23250889de4e2079ad1ede6874cc824bc9dd92db#l2258,
by removing the panic and setting req_alignB to VG_MIN_MALLOC_SZB, I hit the
other issue.

I'm using Valgrind on master, at commit:
d4c9a98527afdbd67b25a1300339a42b9e0a24c2

STEPS TO REPRODUCE
1. Compile and run the following C snippet:

#include <stdlib.h>
#include <stdio.h>

int main() {
    char *p = aligned_alloc(4, 4);

    if(p == NULL) {
        printf("Allocation failed!\n");     
        return 1;
    }

    printf("Allocation succeeded!\n");

    return 0;
}

2. Then run it again under Valgrind

OBSERVED RESULT

The allocation succeeds when run on its own, but with Valgrind fails:

VG_(arena_memalign)(0x58889810, 4, 4)
bad alignment value 4
(it is too small, below the lower limit of 16)
valgrind: the 'impossible' happened:
   VG_(arena_memalign)

EXPECTED RESULT

Both succeeds.

ADDITIONAL INFORMATION

The issue seems to be similar to the other bug I linked above, but here the
requirement on the alignment seems to be more strict and actually connected to
what's required from malloc, but not aligned_alloc, which again is
implementation dependent and on glibc the only limit seems to be that it has to
be a power of 2.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to