|
From: Paul F. <pa...@so...> - 2026-03-01 17:31:39
|
https://sourceware.org/cgit/valgrind/commit/?id=b6903333fea9e3fdce97e6508bcf59a448b9ef52 commit b6903333fea9e3fdce97e6508bcf59a448b9ef52 Author: Paul Floyd <pj...@wa...> Date: Sun Mar 1 18:19:46 2026 +0100 Explain why realloc_size_zero does not use Addr.Block and clean up a volatile cast Diff: --- coregrind/m_syswrap/syswrap-freebsd.c | 10 +--------- memcheck/mc_errors.c | 9 +++++++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index c2e2f50dc9..c9a3939478 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -7026,15 +7026,7 @@ PRE(sys_aio_readv) SET_STATUS_Failure( VKI_EBADF ); } else { SizeT vec_count = (SizeT)iocb->aio_nbytes; -#if defined(__clang__) -#pragma clang diagnostic push - // yes, I know it is volatile -#pragma clang diagnostic ignored "-Wcast-qual" -#endif - struct vki_iovec* p_iovec = (struct vki_iovec*)iocb->aio_buf; -#if defined(__clang__) -#pragma clang diagnostic pop -#endif + struct vki_iovec* p_iovec = (struct vki_iovec*)(uintptr_t)iocb->aio_buf; PRE_MEM_READ("aio_readv(iocb->aio_iov)", (Addr)p_iovec, vec_count*sizeof(struct vki_iovec)); if (ML_(safe_to_deref)(p_iovec, vec_count*sizeof(struct vki_iovec))) { for (SizeT i = 0U; i < vec_count; ++i) { diff --git a/memcheck/mc_errors.c b/memcheck/mc_errors.c index e9a8f3f02e..b8869733fd 100644 --- a/memcheck/mc_errors.c +++ b/memcheck/mc_errors.c @@ -1014,6 +1014,15 @@ void MC_(record_realloc_size_zero) ( ThreadId tid, Addr a ) { MC_Error extra; tl_assert(VG_INVALID_THREADID != tid); + /* + * We can't fill the Block as in freemismatch above. + * That's because if realloc size zero frees we literally do that + * and transform the call into a free before bothering to get the + * old MC_Chunk. + * + * See VG_(maybe_record_error) for a description of how this gets + * filled on demand. + */ extra.Err.ReallocSizeZero.ai.tag = Addr_Undescribed; VG_(maybe_record_error)( tid, Err_ReallocSizeZero, a, /*s*/NULL, &extra ); } |