On Tue, Oct 17, 2023 at 05:41:06PM +0900, Masato Asou wrote: > From: Otto Moerbeek <o...@drijf.net> > Date: Tue, 17 Oct 2023 07:52:12 +0200 > > > On Tue, Oct 17, 2023 at 07:33:47AM +0900, Masato Asou wrote: > > > >> From: Masato Asou <a...@soum.co.jp> > >> Date: Fri, 29 Sep 2023 19:39:12 +0900 (JST) > >> > >> ping > > > > Sorry for not replying earlier. > > No problem :-) > > > The locations are reported > > correctly now. But there are spurious reports of accesses of a 8 byte > > value on each system call. (tested on amd64). > > > > -Otto > > > > ==83949== Use of uninitialised value of size 8 > > ==83949== at 0x4A0CEC2: write (sys/w_write.c:28) > > ==83949== by 0x4A1B322: __sflush (stdio/fflush.c:80) > > ==83949== by 0x49B21E8: __sfvwrite (stdio/fvwrite.c:188) > > ==83949== by 0x4A26FED: __sprint (stdio/vfprintf.c:108) > > ==83949== by 0x4A26FED: __vfprintf (stdio/vfprintf.c:1062) > > ==83949== by 0x4A23CA5: vfprintf (stdio/vfprintf.c:263) > > ==83949== by 0x49EDB54: printf (stdio/printf.c:44) > > ==83949== by 0x109B90: main (m.c:16) > > I know this issue. This is due to the references to the FS (F > segment) registers TCB and TIB made by ENTER_CANCEL_POINT and > LEAVE_CANCEL_POINT during the system call invocation. > > I think this problem should be solved in the `.supp' files (valgrind > --suppressions=<filename>). I am working on a `.supp' file for > OpenBSD. However, this cannot be created quickly yet. Wouldn't it be > better to commit the `.supp' file as a separate modification?
Yes, a separate commit is fine. Would this suppression file end up in pkg-readmes, or does valgrind have a place to store a system-wide default supression file? -Otto > -- > ASOU Masato > > >> > >> > I have fixed the bug you reported when symbols were not printed. > >> > > >> > As shown below, if the lower 12 bits of Virtual Address are 0 and File > >> > Size is 0, then the a.out symbol will not be printed. > >> > > >> > $ readelf -l a.out > >> > </snip> > >> > Program Headers: > >> > Type Offset VirtAddr PhysAddr > >> > FileSiz MemSiz Flags Align > >> > </snip> > >> > LOAD 0x0000000000001000 0x0000000000003000 0x0000000000003000 > >> > 0x0000000000000000 0x0000000000000055 RW 1000 > >> > > >> > From: Otto Moerbeek <o...@drijf.net> > >> > Date: Tue, 5 Sep 2023 07:40:18 +0200 > >> > > >> >> On Tue, Sep 05, 2023 at 09:38:40AM +0900, Masato Asou wrote: > >> >> > >> >>> hi, > >> >>> > >> >>> I have fixed a bug in Valgrind. The Valgrind could not detect access > >> >>> outside the range of malloc. > >> >>> > >> >>> comments, ok? > >> >> > >> >> This works much better that before. Thanks for working on this! > >> >> > >> >> It now detects out of bounds read and writes correctly. A double > >> >> free is detected. > >> >> Also, the spurious reports for accesses to errno are gone. > >> >> > >> >> It does not report proper locations though, even if I compile my test > >> >> program with -g: > >> >> > >> >> ==23912== Invalid read of size 1 > >> >> ==23912== at 0x109B5D: ??? (in ./a.out) > >> >> ==23912== by 0x1098D1: ??? (in ./a.out) > >> >> ==23912== Address 0x4a42840 is 0 bytes after a block of size 10,240 > >> >> alloc'd > >> >> ==23912== at 0x493A3A9: malloc (vg_replace_malloc.c:435) > >> >> ==23912== by 0x109B32: ??? (in ./a.out) > >> >> ==23912== by 0x1098D1: ??? (in ./a.out) > >> >> ==23912== > >> >> 0 > >> > > >> > The a.out symbol is now printed as shown below: > >> > > >> > $ cat malloctest.c > >> > #include <stdlib.h> > >> > #include <stdio.h> > >> > > >> > int > >> > main(int argc, char *argv[]) > >> > { > >> > size_t sz = atoi(argv[1]); > >> > unsigned char *p = malloc(sz); > >> > printf("%p\n", p); > >> > p[sz] = 0; > >> > printf("%x\n", p[sz]); > >> > free(p); > >> > free(p); > >> > return 0; > >> > } > >> > $ cc -g malloctest.c > >> > $ valgrind ./a.out 128 > >> > ==21074== Memcheck, a memory error detector > >> > ==21074== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al. > >> > ==21074== Using Valgrind-3.21.0 and LibVEX; rerun with -h for copyright > >> > info > >> > ==21074== Command: ./a.out 128 > >> > ==21074== > >> > ==21074== Use of uninitialised value of size 8 > >> > ==21074== at 0x49C34CD: write (sys/w_write.c:26) > >> > ==21074== by 0x4A150D2: __sflush (stdio/fflush.c:80) > >> > ==21074== by 0x49B99C8: __sfvwrite (stdio/fvwrite.c:191) > >> > ==21074== by 0x4979E4D: __sprint (stdio/vfprintf.c:108) > >> > ==21074== by 0x4979E4D: __vfprintf (stdio/vfprintf.c:1064) > >> > ==21074== by 0x4976B05: vfprintf (stdio/vfprintf.c:263) > >> > ==21074== by 0x49D6434: printf (stdio/printf.c:44) > >> > ==21074== by 0x109B48: main (malloctest.c:9) > >> > ==21074== > >> > ==21074== Use of uninitialised value of size 8 > >> > ==21074== at 0x49C34DE: write (sys/w_write.c:26) > >> > ==21074== by 0x4A150D2: __sflush (stdio/fflush.c:80) > >> > ==21074== by 0x49B99C8: __sfvwrite (stdio/fvwrite.c:191) > >> > ==21074== by 0x4979E4D: __sprint (stdio/vfprintf.c:108) > >> > ==21074== by 0x4979E4D: __vfprintf (stdio/vfprintf.c:1064) > >> > ==21074== by 0x4976B05: vfprintf (stdio/vfprintf.c:263) > >> > ==21074== by 0x49D6434: printf (stdio/printf.c:44) > >> > ==21074== by 0x109B48: main (malloctest.c:9) > >> > > >> >> ==23912== Invalid free() / delete / delete[] / realloc() > >> >> ==23912== at 0x493C981: free (vg_replace_malloc.c:978) > >> >> ==23912== by 0x109B80: ??? (in ./a.out) > >> >> ==23912== by 0x1098D1: ??? (in ./a.out) > >> >> ==23912== Address 0x4a40040 is 0 bytes inside a block of size 10,240 > >> >> free'd > >> >> ==23912== at 0x493C981: free (vg_replace_malloc.c:978) > >> >> ==23912== by 0x109B77: ??? (in ./a.out) > >> >> ==23912== by 0x1098D1: ??? (in ./a.out) > >> >> ==23912== Block was alloc'd at > >> >> ==23912== at 0x493A3A9: malloc (vg_replace_malloc.c:435) > >> >> ==23912== by 0x109B32: ??? (in ./a.out) > >> >> ==23912== by 0x1098D1: ??? (in ./a.out) > >> >> > >> >> addr2line -e ./a.out 0x109B80 also does not succeed in translating the > >> >> address. > >> > > >> > Address reported by Valgrind cannot be used for addr2line. Because > >> > the address is the address of the area where Valgrind mapped a.out > >> > with mmap(). > >> > > >> > > >> > The Makefile and patch-coregrind_m_replacemalloc_vg_replace_malloc_c > >> > in the following diff are the same as the first reported diff. > >> > > >> > ok, comments? > >> > -- > >> > ASOU Masato > >> > > >> > Index: devel/valgrind/Makefile > >> > =================================================================== > >> > RCS file: /cvs/ports/devel/valgrind/Makefile,v > >> > retrieving revision 1.32 > >> > diff -u -p -r1.32 Makefile > >> > --- devel/valgrind/Makefile 21 Sep 2023 09:50:07 -0000 1.32 > >> > +++ devel/valgrind/Makefile 29 Sep 2023 09:44:46 -0000 > >> > @@ -5,7 +5,7 @@ CATEGORIES = devel > >> > > >> > V = 3.21.0 > >> > DISTNAME = valgrind-${V} > >> > -REVISION = 0 > >> > +REVISION = 1 > >> > EXTRACT_SUFX = .tar.bz2 > >> > > >> > SITES = https://sourceware.org/pub/valgrind/ > >> > Index: > >> > devel/valgrind/patches/patch-coregrind_m_aspacemgr_aspacemgr_linux_c > >> > =================================================================== > >> > RCS file: > >> > /cvs/ports/devel/valgrind/patches/patch-coregrind_m_aspacemgr_aspacemgr_linux_c,v > >> > retrieving revision 1.1 > >> > diff -u -p -r1.1 patch-coregrind_m_aspacemgr_aspacemgr_linux_c > >> > --- devel/valgrind/patches/patch-coregrind_m_aspacemgr_aspacemgr_linux_c > >> > 18 Jul 2023 06:17:15 -0000 1.1 > >> > +++ devel/valgrind/patches/patch-coregrind_m_aspacemgr_aspacemgr_linux_c > >> > 29 Sep 2023 09:44:46 -0000 > >> > @@ -18,7 +18,41 @@ > >> > = (Addr) 0x04000000; // 64M > >> > #else > >> > #endif > >> > -@@ -1550,7 +1550,7 @@ > >> > +@@ -685,6 +685,7 @@ > >> > + break; > >> > + > >> > + case SkFileC: case SkFileV: > >> > ++#if !defined(VGO_openbsd) > >> > + if (s1->hasR == s2->hasR > >> > + && s1->hasW == s2->hasW && s1->hasX == s2->hasX > >> > + && s1->dev == s2->dev && s1->ino == s2->ino > >> > +@@ -695,6 +696,25 @@ > >> > + ML_(am_dec_refcount)(s1->fnIdx); > >> > + return True; > >> > + } > >> > ++ // The following is an excerpt from `readelf -l a.out'. > >> > ++ // > >> > ++ // LOAD 0x0000000000000e20 0x0000000000002e20 > >> > 0x0000000000002e20 > >> > ++ // 0x00000000000001e0 0x00000000000001e0 RW 1000 > >> > ++ // LOAD 0x0000000000001000 0x0000000000003000 > >> > 0x0000000000003000 > >> > ++ // 0x0000000000000000 0x0000000000000055 RW 1000 > >> > ++ // > >> > ++ // The above two areas are determined to be contiguous area > >> > in the > >> > ++ // above `if' statement, and they are merged by > >> > preen_nsegments(). > >> > ++ // Then, di->fsm.rw_map_count in the following `if' statement > >> > in > >> > ++ // VG_(di_notify_mmap)() would be 1, which does not match > >> > ++ // rw_load_count, and di_notify_ACHIEVE_ACCEPT_STATE() is not > >> > called. > >> > ++ // In the above program header, rw_load_count is 2. > >> > ++ // > >> > ++ // if (di->fsm.have_rx_map && > >> > ++ // rw_load_count >= 1 && > >> > ++ // di->fsm.rw_map_count == rw_load_count) { > >> > ++ // return di_notify_ACHIEVE_ACCEPT_STATE ( di ); > >> > ++#endif > >> > + break; > >> > + > >> > + case SkShmC: > >> > +@@ -1550,7 +1570,7 @@ > >> > if (filename || (dev != 0 && ino != 0)) > >> > seg.kind = SkFileV; > >> > > >> > @@ -27,7 +61,7 @@ > >> > // GrP fixme no dev/ino on darwin > >> > if (offset != 0) > >> > seg.kind = SkFileV; > >> > -@@ -2697,7 +2697,11 @@ > >> > +@@ -2697,7 +2717,11 @@ > >> > a client request to call the outer VG_(am_get_advisory). */ > >> > sres = VG_(am_do_mmap_NO_NOTIFY)( > >> > advised, length, > >> > @@ -39,7 +73,7 @@ > >> > VKI_MAP_FIXED|VKI_MAP_PRIVATE|VKI_MAP_ANONYMOUS, > >> > VM_TAG_VALGRIND, 0 > >> > ); > >> > -@@ -2742,6 +2746,54 @@ > >> > +@@ -2742,6 +2766,54 @@ > >> > return sres; > >> > } > >> > > >> > @@ -94,7 +128,7 @@ > >> > /* Really just a wrapper around VG_(am_mmap_anon_float_valgrind). */ > >> > > >> > SysRes VG_(am_shadow_alloc)(SizeT size) > >> > -@@ -3896,10 +3948,14 @@ > >> > +@@ -3896,10 +3968,14 @@ > >> > /*------END-procmaps-parser-for-Darwin---------------------------*/ > >> > > >> > /*------BEGIN-procmaps-parser-for-Freebsd------------------------*/ > >> > @@ -111,7 +145,7 @@ > >> > > >> > /* static ... to keep it out of the stack frame. */ > >> > static char procmap_buf[M_PROCMAP_BUF]; > >> > -@@ -3911,6 +3967,7 @@ > >> > +@@ -3911,6 +3987,7 @@ > >> > void (*record_gap)( Addr addr, SizeT len ) > >> > ) > >> > { > >> > @@ -119,7 +153,7 @@ > >> > Addr start, endPlusOne, gapStart; > >> > char* filename; > >> > char *p; > >> > -@@ -3968,6 +4025,57 @@ > >> > +@@ -3968,6 +4045,57 @@ > >> > > >> > if (record_gap && gapStart < Addr_MAX) > >> > (*record_gap) ( gapStart, Addr_MAX - gapStart + 1 ); > >> > Index: > >> > devel/valgrind/patches/patch-coregrind_m_replacemalloc_vg_replace_malloc_c > >> > =================================================================== > >> > RCS file: > >> > devel/valgrind/patches/patch-coregrind_m_replacemalloc_vg_replace_malloc_c > >> > diff -N > >> > devel/valgrind/patches/patch-coregrind_m_replacemalloc_vg_replace_malloc_c > >> > --- /dev/null 1 Jan 1970 00:00:00 -0000 > >> > +++ > >> > devel/valgrind/patches/patch-coregrind_m_replacemalloc_vg_replace_malloc_c > >> > 29 Sep 2023 09:44:46 -0000 > >> > @@ -0,0 +1,263 @@ > >> > +--- coregrind/m_replacemalloc/vg_replace_malloc.c.orig > >> > ++++ coregrind/m_replacemalloc/vg_replace_malloc.c > >> > +@@ -222,7 +222,7 @@ > >> > + #define SET_ERRNO_ENOMEM if (__errno_location) \ > >> > + (*__errno_location ()) = VKI_ENOMEM; > >> > + #define SET_ERRNO_EINVAL {} > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + extern int *__error (void) __attribute__((weak)); > >> > + #define SET_ERRNO_ENOMEM if (__error) \ > >> > + (*__error ()) = VKI_ENOMEM; > >> > +@@ -430,7 +430,7 @@ > >> > + ALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc, malloc); > >> > + ALLOC_or_NULL(SO_SYN_MALLOC, malloc, malloc); > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + ALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc, malloc); > >> > + ALLOC_or_NULL(SO_SYN_MALLOC, malloc, malloc); > >> > + > >> > +@@ -472,7 +472,7 @@ > >> > + ALLOC_or_BOMB(SO_SYN_MALLOC, _Znwm, __builtin_new); > >> > + #endif > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator new(unsigned int) > >> > + #if VG_WORDSIZE == 4 > >> > + ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znwj, __builtin_new); > >> > +@@ -532,7 +532,7 @@ > >> > + ALLOC_or_BOMB_ALIGNED(SO_SYN_MALLOC, _ZnwmSt11align_val_t, > >> > __builtin_new_aligned); > >> > + #endif > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator new(unsigned int) > >> > + #if VG_WORDSIZE == 4 > >> > + ALLOC_or_BOMB_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZnwjSt11align_val_t, > >> > __builtin_new_aligned); > >> > +@@ -592,7 +592,7 @@ > >> > + ALLOC_or_NULL(SO_SYN_MALLOC, _ZnwmRKSt9nothrow_t, > >> > __builtin_new); > >> > + #endif > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator new(unsigned, std::nothrow_t const&) > >> > + #if VG_WORDSIZE == 4 > >> > + ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnwjRKSt9nothrow_t, > >> > __builtin_new); > >> > +@@ -652,7 +652,7 @@ > >> > + ALLOC_or_NULL_ALIGNED(SO_SYN_MALLOC, > >> > _ZnwmSt11align_val_tRKSt9nothrow_t, __builtin_new_aligned); > >> > + #endif > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator new(unsigned int, std::align_val_t, std::nothrow_t const&) > >> > + #if VG_WORDSIZE == 4 > >> > + ALLOC_or_NULL_ALIGNED(VG_Z_LIBSTDCXX_SONAME, > >> > _ZnwjSt11align_val_tRKSt9nothrow_t, __builtin_new_aligned); > >> > +@@ -714,7 +714,7 @@ > >> > + ALLOC_or_BOMB(SO_SYN_MALLOC, _Znam, > >> > __builtin_vec_new ); > >> > + #endif > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator new[](unsigned int) > >> > + #if VG_WORDSIZE == 4 > >> > + ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znaj, > >> > __builtin_vec_new ); > >> > +@@ -774,7 +774,7 @@ > >> > + ALLOC_or_BOMB_ALIGNED(SO_SYN_MALLOC, _ZnamSt11align_val_t, > >> > __builtin_vec_new_aligned ); > >> > + #endif > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator new[](unsigned int, std::align_val_t) > >> > + #if VG_WORDSIZE == 4 > >> > + ALLOC_or_BOMB_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZnajSt11align_val_t, > >> > __builtin_vec_new_aligned ); > >> > +@@ -835,7 +835,7 @@ > >> > + ALLOC_or_NULL(SO_SYN_MALLOC, _ZnamRKSt9nothrow_t, > >> > __builtin_vec_new ); > >> > + #endif > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator new[](unsigned, std::nothrow_t const&) > >> > + #if VG_WORDSIZE == 4 > >> > + ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnajRKSt9nothrow_t, > >> > __builtin_vec_new ); > >> > +@@ -895,7 +895,7 @@ > >> > + ALLOC_or_NULL_ALIGNED(SO_SYN_MALLOC, > >> > _ZnamSt11align_val_tRKSt9nothrow_t, __builtin_vec_new_aligned ); > >> > + #endif > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator new[](unsigned int, std::align_val_t, std::nothrow_t > >> > const&) > >> > + #if VG_WORDSIZE == 4 > >> > + ALLOC_or_NULL_ALIGNED(VG_Z_LIBSTDCXX_SONAME, > >> > _ZnajSt11align_val_tRKSt9nothrow_t, __builtin_vec_new_aligned ); > >> > +@@ -973,7 +973,7 @@ > >> > + FREE(VG_Z_LIBC_SONAME, free, free ); > >> > + FREE(SO_SYN_MALLOC, free, free ); > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + FREE(VG_Z_LIBC_SONAME, free, free ); > >> > + FREE(SO_SYN_MALLOC, free, free ); > >> > + > >> > +@@ -1024,7 +1024,7 @@ > >> > + FREE(VG_Z_LIBC_SONAME, _ZdlPv, __builtin_delete ); > >> > + FREE(SO_SYN_MALLOC, _ZdlPv, __builtin_delete ); > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPv, __builtin_delete ); > >> > + FREE(VG_Z_LIBCXX_SONAME, _ZdlPv, __builtin_delete ); > >> > + FREE(SO_SYN_MALLOC, _ZdlPv, __builtin_delete ); > >> > +@@ -1072,7 +1072,7 @@ > >> > + DELETE_SIZED(SO_SYN_MALLOC, _ZdlPvm, > >> > __builtin_delete ); > >> > + #endif > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator delete(void*, unsigned int) > >> > + #if __SIZEOF_SIZE_T__ == 4 > >> > + DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvj, > >> > __builtin_delete ); > >> > +@@ -1160,7 +1160,7 @@ > >> > + DELETE_SIZED_ALIGNED(SO_SYN_MALLOC, _ZdlPvmSt11align_val_t, > >> > __builtin_delete_aligned ); > >> > + #endif > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator delete(void*, std::align_val_t) > >> > + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdlPvSt11align_val_t, > >> > __builtin_delete_aligned ); > >> > + DELETE_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdlPvSt11align_val_t, > >> > __builtin_delete_aligned ); > >> > +@@ -1224,7 +1224,7 @@ > >> > + FREE(VG_Z_LIBC_SONAME, _ZdlPvRKSt9nothrow_t, __builtin_delete ); > >> > + FREE(SO_SYN_MALLOC, _ZdlPvRKSt9nothrow_t, __builtin_delete ); > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator delete(void*, std::nothrow_t const&) > >> > + FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvRKSt9nothrow_t, __builtin_delete ); > >> > + FREE(VG_Z_LIBCXX_SONAME, _ZdlPvRKSt9nothrow_t, __builtin_delete ); > >> > +@@ -1254,7 +1254,7 @@ > >> > + > >> > + // no sized version of this operator > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator delete(void*, std::align_val_t, std::nothrow_t const&) > >> > + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, > >> > _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); > >> > + DELETE_ALIGNED(VG_Z_LIBCXX_SONAME, > >> > _ZdlPvSt11align_val_tRKSt9nothrow_t, __builtin_delete_aligned ); > >> > +@@ -1288,7 +1288,7 @@ > >> > + FREE(VG_Z_LIBC_SONAME, _ZdaPv, > >> > __builtin_vec_delete ); > >> > + FREE(SO_SYN_MALLOC, _ZdaPv, > >> > __builtin_vec_delete ); > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator delete[](void*) > >> > + FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPv, > >> > __builtin_vec_delete ); > >> > + FREE(VG_Z_LIBCXX_SONAME, _ZdaPv, > >> > __builtin_vec_delete ); > >> > +@@ -1323,7 +1323,7 @@ > >> > + DELETE_SIZED(SO_SYN_MALLOC, _ZdaPvm, > >> > __builtin_vec_delete ); > >> > + #endif > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator delete[](void*, unsigned int) > >> > + #if __SIZEOF_SIZE_T__ == 4 > >> > + DELETE_SIZED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvj, > >> > __builtin_vec_delete ); > >> > +@@ -1383,7 +1383,7 @@ > >> > + DELETE_SIZED_ALIGNED(SO_SYN_MALLOC, _ZdaPvmSt11align_val_t, > >> > __builtin_vec_delete_aligned ); > >> > + #endif > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator delete[](void*, std::align_val_t) > >> > + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, _ZdaPvSt11align_val_t, > >> > __builtin_vec_delete_aligned ); > >> > + DELETE_ALIGNED(VG_Z_LIBCXX_SONAME, _ZdaPvSt11align_val_t, > >> > __builtin_vec_delete_aligned ); > >> > +@@ -1447,7 +1447,7 @@ > >> > + FREE(VG_Z_LIBC_SONAME, _ZdaPvRKSt9nothrow_t, > >> > __builtin_vec_delete ); > >> > + FREE(SO_SYN_MALLOC, _ZdaPvRKSt9nothrow_t, > >> > __builtin_vec_delete ); > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator delete[](void*, std::nothrow_t const&) > >> > + FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvRKSt9nothrow_t, > >> > __builtin_vec_delete ); > >> > + FREE(VG_Z_LIBCXX_SONAME, _ZdaPvRKSt9nothrow_t, > >> > __builtin_vec_delete ); > >> > +@@ -1477,7 +1477,7 @@ > >> > + > >> > + // no sized version of this operator > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + // operator delete[](void*, std::align_val_t, std::nothrow_t const&) > >> > + DELETE_ALIGNED(VG_Z_LIBSTDCXX_SONAME, > >> > _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); > >> > + DELETE_ALIGNED(VG_Z_LIBCXX_SONAME, > >> > _ZdaPvSt11align_val_tRKSt9nothrow_t, __builtin_vec_delete_aligned ); > >> > +@@ -1553,7 +1553,7 @@ > >> > + CALLOC(VG_Z_LIBC_SONAME, calloc); > >> > + CALLOC(SO_SYN_MALLOC, calloc); > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + CALLOC(VG_Z_LIBC_SONAME, calloc); > >> > + CALLOC(SO_SYN_MALLOC, calloc); > >> > + > >> > +@@ -1648,7 +1648,7 @@ > >> > + REALLOC(VG_Z_LIBC_SONAME, realloc); > >> > + REALLOC(SO_SYN_MALLOC, realloc); > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + REALLOC(VG_Z_LIBC_SONAME, realloc); > >> > + REALLOC(SO_SYN_MALLOC, realloc); > >> > + REALLOCF(VG_Z_LIBC_SONAME, reallocf); > >> > +@@ -1734,7 +1734,7 @@ > >> > + return v; \ > >> > + } > >> > + > >> > +-#if defined(VGO_freebsd) > >> > ++#if defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + #define VG_MEMALIGN_MAKE_SIZE_MULTIPLE_ALIGN 1 > >> > + #else > >> > + #define VG_MEMALIGN_MAKE_SIZE_MULTIPLE_ALIGN 0 > >> > +@@ -1834,7 +1834,7 @@ > >> > + MEMALIGN(VG_Z_LIBC_SONAME, memalign); > >> > + MEMALIGN(SO_SYN_MALLOC, memalign); > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + MEMALIGN(VG_Z_LIBC_SONAME, memalign); > >> > + MEMALIGN(SO_SYN_MALLOC, memalign); > >> > + > >> > +@@ -1890,7 +1890,7 @@ > >> > + VALLOC(VG_Z_LIBC_SONAME, valloc); > >> > + VALLOC(SO_SYN_MALLOC, valloc); > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + VALLOC(VG_Z_LIBC_SONAME, valloc); > >> > + VALLOC(SO_SYN_MALLOC, valloc); > >> > + > >> > +@@ -2031,7 +2031,7 @@ > >> > + POSIX_MEMALIGN(VG_Z_LIBC_SONAME, posix_memalign); > >> > + POSIX_MEMALIGN(SO_SYN_MALLOC, posix_memalign); > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + POSIX_MEMALIGN(VG_Z_LIBC_SONAME, posix_memalign); > >> > + POSIX_MEMALIGN(SO_SYN_MALLOC, posix_memalign); > >> > + > >> > +@@ -2176,7 +2176,7 @@ > >> > + ALIGNED_ALLOC(VG_Z_LIBC_SONAME, aligned_alloc); > >> > + ALIGNED_ALLOC(SO_SYN_MALLOC, aligned_alloc); > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + ALIGNED_ALLOC(G_Z_LIBC_SONAME, aligned_alloc); > >> > + ALIGNED_ALLOC(SO_SYN_MALLOC, aligned_alloc); > >> > + > >> > +@@ -2220,7 +2220,7 @@ > >> > + MALLOC_USABLE_SIZE(SO_SYN_MALLOC, dlmalloc_usable_size); > >> > + # endif > >> > + > >> > +-#elif defined(VGO_freebsd) > >> > ++#elif defined(VGO_freebsd) || defined(VGO_openbsd) > >> > + MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, malloc_usable_size); > >> > + MALLOC_USABLE_SIZE(SO_SYN_MALLOC, malloc_usable_size); > >> > + > >> > Index: devel/valgrind/patches/patch-coregrind_m_ume_elf_c > >> > =================================================================== > >> > RCS file: /cvs/ports/devel/valgrind/patches/patch-coregrind_m_ume_elf_c,v > >> > retrieving revision 1.3 > >> > diff -u -p -r1.3 patch-coregrind_m_ume_elf_c > >> > --- devel/valgrind/patches/patch-coregrind_m_ume_elf_c 18 Jul 2023 > >> > 06:17:15 -0000 1.3 > >> > +++ devel/valgrind/patches/patch-coregrind_m_ume_elf_c 29 Sep 2023 > >> > 09:44:46 -0000 > >> > @@ -71,8 +71,21 @@ > >> > for (i = 0; i < e->e.e_phnum; i++) { > >> > ESZ(Phdr) *ph = &e->p[i]; > >> > ESZ(Addr) addr, bss, brkaddr; > >> > -@@ -437,6 +476,11 @@ > >> > +@@ -435,8 +474,24 @@ > >> > + filesz = ph->p_filesz; > >> > + bss = addr+filesz; > >> > memsz = ph->p_memsz; > >> > ++#if defined(VGO_openbsd) > >> > ++ // On OpenBSD, p_filesz of the BSS area is set to 0. Also, if > >> > the lower > >> > ++ // 12 bits of addr is 0, bss and addr have the same value. > >> > Therefore, > >> > ++ // VG_PGROUNDUP(bss)-VG_PGROUNDDN(addr) = 0, the following > >> > ++ // `if (VG_PGROUNDUP(bss)-VG_PGROUNDDN(addr)' statement becomes > >> > false, > >> > ++ // and VG_(am_mmap_file_fixed_client)() is not called. > >> > Additionally, > >> > ++ // di_notify_ACHIEVE_ACCEPT_STATE() is not called and the > >> > first_epoch > >> > ++ // variable in DebugInfo is not set to a valid value. > >> > ++ if ((addr & 0xfff) == 0 && filesz == 0) > >> > ++ bss += memsz; > >> > ++#endif > >> > brkaddr = addr+memsz; > >> > > >> > +#if defined(VGO_openbsd) > >> > @@ -83,7 +96,7 @@ > >> > // Tom says: In the following, do what the Linux kernel does and > >> > only > >> > // map the pages that are required instead of rounding > >> > everything to > >> > // the specified alignment (ph->p_align). (AMD64 doesn't work > >> > if you > >> > -@@ -460,6 +504,7 @@ > >> > +@@ -460,6 +515,7 @@ > >> > if (memsz > filesz) { > >> > UInt bytes; > >> > > >> > @@ -91,7 +104,7 @@ > >> > bytes = VG_PGROUNDUP(brkaddr)-VG_PGROUNDUP(bss); > >> > if (bytes > 0) { > >> > if (0) VG_(debugLog)(0,"ume","mmap_anon_fixed_client > >> > #2\n"); > >> > -@@ -478,6 +523,42 @@ > >> > +@@ -478,6 +534,42 @@ > >> > bytes = VKI_PAGE_SIZE - bytes; > >> > VG_(memset)((void *)bss, 0, bytes); > >> > } > >> > @@ -134,7 +147,7 @@ > >> > } > >> > } > >> > > >> > -@@ -879,7 +960,7 @@ > >> > +@@ -879,7 +971,7 @@ > >> > return 0; > >> > } > >> > > >> >