VirtualBox

Changeset 72625 in vbox for trunk


Ignore:
Timestamp:
Jun 20, 2018 12:21:30 PM (7 years ago)
Author:
vboxsync
Message:

iprt/mem.h: Added RTMEM_WILL_LEAK and RTMEM_MAY_LEAK macros for marking memory as leaked on higher levels. Made VBOX_GCC_SANITIZER_FLAGS define an IPRT friendly indicator, is VBOX_XXXX is still stricly forbidden in Runtime/.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Config.kmk

    r72602 r72625  
    29302930ifdef VBOX_WITH_GCC_SANITIZER
    29312931 VBOX_GCC_SANITIZER_FLAGS := \
    2932         -fsanitize=undefined \
    2933         -fsanitize=address \
    2934         -fsanitize=return \
    2935         -fsanitize=bounds \
    2936         -fsanitize=object-size \
    2937         -fno-sanitize=alignment \
    2938         -fno-sanitize=vptr \
    2939         -fno-common \
    2940         -include sanitizer/lsan_interface.h \
    2941         -DVBOX_WITH_GCC_SANITIZER
     2932        -fsanitize=undefined \
     2933        -fsanitize=address \
     2934        -fsanitize=return \
     2935        -fsanitize=bounds \
     2936        -fsanitize=object-size \
     2937        -fno-sanitize=alignment \
     2938        -fno-sanitize=vptr \
     2939        -fno-common \
     2940        -include sanitizer/lsan_interface.h \
     2941        -DIPRT_WITH_GCC_SANITIZER \
     2942        -DVBOX_WITH_GCC_SANITIZER
    29422943else
    29432944 VBOX_GCC_SANITIZER_FLAGS =
  • trunk/include/iprt/mem.h

    r69105 r72625  
    499499 */
    500500RTDECL(void) RTMemWipeThoroughly(void *pv, size_t cb, size_t cMinPasses) RT_NO_THROW_PROTO;
     501
     502
     503/** @def RTMEM_WILL_LEAK
     504 * Macro for hinting that a memory allocation @a a_pv will leak.
     505 *
     506 * @note This shall only be used in code that doesn't allocate the object.
     507 *       Code allocating memory knowing it will leak shall start the allocation
     508 *       tag string with 'will-leak:'.
     509 */
     510/** @def RTMEM_MAY_LEAK
     511 * Macro for hinting that a memory allocation @a a_pv may leak.
     512 *
     513 * @note This shall only be used in code that doesn't allocate the object.
     514 *       Code allocating memory knowing it may leak shall start the allocation
     515 *       tag string with 'may-leak:'.
     516 */
     517#ifdef IPRT_WITH_GCC_SANITIZER
     518# define RTMEM_WILL_LEAK(a_pv)   __lsan_ignore_object(a_pv)
     519# define RTMEM_MAY_LEAK(a_pv)    __lsan_ignore_object(a_pv)
     520#else
     521# define RTMEM_WILL_LEAK(a_pv)   do { } while (0)
     522# define RTMEM_MAY_LEAK(a_pv)    do { } while (0)
     523#endif
     524
    501525
    502526#ifdef IN_RING0
  • trunk/src/VBox/Runtime/r3/alloc.cpp

    r72613 r72625  
    8686
    8787
    88 #ifdef VBOX_WITH_GCC_SANITIZER
     88#ifdef IPRT_WITH_GCC_SANITIZER
    8989/**
    9090 * Checks if @a pszTag is a leak tag.
     
    118118        && pszTag[8] == 'k';
    119119}
    120 #endif /* VBOX_WITH_GCC_SANITIZER */
     120#endif /* IPRT_WITH_GCC_SANITIZER */
    121121
    122122
     
    158158              , ("pv=%p RTMEM_ALIGNMENT=%#x\n", pv, RTMEM_ALIGNMENT));
    159159#endif /* !RTALLOC_USE_EFENCE */
    160 #ifdef VBOX_WITH_GCC_SANITIZER
     160#ifdef IPRT_WITH_GCC_SANITIZER
    161161    if (rtMemIsLeakTag(pszTag))
    162162        __lsan_ignore_object(pv);
     
    186186              , ("pv=%p RTMEM_ALIGNMENT=%#x\n", pv, RTMEM_ALIGNMENT));
    187187#endif /* !RTALLOC_USE_EFENCE */
    188 #ifdef VBOX_WITH_GCC_SANITIZER
     188#ifdef IPRT_WITH_GCC_SANITIZER
    189189    if (rtMemIsLeakTag(pszTag))
    190190        __lsan_ignore_object(pv);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette