llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.71k stars 10.94k forks source link

clang-format crash #59659

Closed SHowe02066 closed 1 year ago

SHowe02066 commented 1 year ago
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.  Program arguments: /usr/bin/clang-format-14 -i /home/dev/VS_SystemTargets/dependents/VS_HardwareInterface/HardwareInterface/inc/Native/stm32h7xx.h -style=file:/home/dev/VS_SystemTargets/dependents/VS_Pipeline/cmake/.clang-format
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamEi+0x31)[0x7f4520ce7d01]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0xee)[0x7f4520ce5a3e]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(+0xe40236)[0x7f4520ce8236]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7f451f98f520]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6format32LeftRightQualifierAlignmentFixer11analyzeLeftERKNS_13SourceManagerERKNS0_18AdditionalKeywordsERNS_7tooling12ReplacementsEPKNS0_11FormatTokenERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_3tok9TokenKindE+0x231)[0x7f45293b49f1]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6format32LeftRightQualifierAlignmentFixer7analyzeERNS0_14TokenAnnotatorERN4llvm15SmallVectorImplIPNS0_13AnnotatedLineEEERNS0_16FormatTokenLexerE+0x148)[0x7f45293b5228]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6format13TokenAnalyzer7processEv+0x376)[0x7f45293c0016]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(+0x2c3b6aa)[0x7f45293b56aa]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6format23QualifierAlignmentFixer7analyzeERNS0_14TokenAnnotatorERN4llvm15SmallVectorImplIPNS0_13AnnotatedLineEEERNS0_16FormatTokenLexerE+0x177)[0x7f45293b3047]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6format13TokenAnalyzer7processEv+0x376)[0x7f45293c0016]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(+0x2c28d7a)[0x7f45293a2d7a]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6format8internal8reformatERKNS0_11FormatStyleEN4llvm9StringRefENS5_8ArrayRefINS_7tooling5RangeEEEjjjS6_PNS0_23FormattingAttemptStatusE+0x8db)[0x7f452938f8bb]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6format8reformatERKNS0_11FormatStyleEN4llvm9StringRefENS4_8ArrayRefINS_7tooling5RangeEEES5_PNS0_23FormattingAttemptStatusE+0x51)[0x7f4529390691]
/usr/bin/clang-format-14[0x40b129]
/usr/bin/clang-format-14[0x409335]
/lib/x86_64-linux-gnu/libc.so.6(+0x29d90)[0x7f451f976d90]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80)[0x7f451f976e40]
/usr/bin/clang-format-14[0x406475]
/home/dev/VS_SystemTargets/dependents/VS_Pipeline/cmake/format.sh: line 47:  8700 Segmentation fault      (core dumped) "$CLANG_FORMAT" -i "$FILE" -style=file:"$SCRIPT_DIR/.clang-format"
shafik commented 1 year ago

This looks like a clang-format crash from the mangled names, do you have a way to reproduce this, if so that would help in debugging the problem.

SHowe02066 commented 1 year ago
/**
 * Copyright 2022 Vicarious Surgical Inc.
 * @file    stm32h7xx.h
 * @brief   CMSIS STM32H7xx Device Peripheral Access Layer Header File.
 * For use in simulation on the native environment.
 * @details originally from VS_HardwareInterface/HardwareInterface/external/CMSIS/Device/ST/STM32H7xx/Include/stm32h7xx.h
 */

#ifndef STM32H7xx_H
#define STM32H7xx_H

// Definitions for native simulation
#include <stdint.h>
#define __CLZ(v) 31
#define __COMPILER_BARRIER()
#define __DSB()
#define __I
#define __IM
#define __IO
#define __IOM
#define __ISB()
#define __NO_RETURN
#define __NOP()
#define __OM
#define __RBIT() 0
#define __STATIC_INLINE static inline
#define __WFI()
#define __WFE()

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/** @addtogroup CMSIS
 * @{
 */

/** @addtogroup stm32h7xx
 * @{
 */

    /** @addtogroup Library_configuration_section
     * @{
     */

    /**
     * @brief STM32 Family
     */
    #if !defined(STM32H7)
        #define STM32H7
    #endif /* STM32H7 */

/* Uncomment the line below according to the target STM32H7 device used in your
   application
  */

    #if !defined(STM32H743xx) && !defined(STM32H753xx) && !defined(STM32H750xx) && !defined(STM32H742xx) &&   \
        !defined(STM32H745xx) && !defined(STM32H745xG) && !defined(STM32H755xx) && !defined(STM32H747xx) &&   \
        !defined(STM32H747xG) && !defined(STM32H757xx) && !defined(STM32H7A3xx) && !defined(STM32H7A3xxQ) &&  \
        !defined(STM32H7B3xx) && !defined(STM32H7B3xxQ) && !defined(STM32H7B0xx) && !defined(STM32H7B0xxQ) && \
        !defined(STM32H735xx) && !defined(STM32H733xx) && !defined(STM32H730xx) && !defined(STM32H730xxQ) &&  \
        !defined(STM32H725xx) && !defined(STM32H723xx)
    /* #define STM32H742xx */  /*!< STM32H742VI, STM32H742ZI, STM32H742AI, STM32H742II, STM32H742BI, STM32H742XI Devices
                                */
    /* #define STM32H743xx */  /*!< STM32H743VI, STM32H743ZI, STM32H743AI, STM32H743II, STM32H743BI, STM32H743XI Devices
                                */
    /* #define STM32H753xx */  /*!< STM32H753VI, STM32H753ZI, STM32H753AI, STM32H753II, STM32H753BI, STM32H753XI Devices
                                */
    /* #define STM32H750xx */  /*!< STM32H750V, STM32H750I, STM32H750X Devices */
    /* #define STM32H747xx */  /*!< STM32H747ZI, STM32H747AI, STM32H747II, STM32H747BI, STM32H747XI Devices */
    /* #define STM32H747xG */  /*!< STM32H747AG, STM32H747IG, STM32H747BG, STM32H747XG */
    /* #define STM32H757xx */  /*!< STM32H757ZI, STM32H757AI, STM32H757II, STM32H757BI, STM32H757XI Devices */
    /* #define STM32H745xx */  /*!< STM32H745ZI, STM32H745II, STM32H745BI, STM32H745XI Devices  */
    /* #define STM32H745xG */  /*!< STM32H745ZG, STM32H745IG, STM32H745BG, STM32H745XG Devices  */
    /* #define STM32H755xx */  /*!< STM32H755ZI, STM32H755II, STM32H755BI, STM32H755XI Devices  */
    /* #define STM32H7B0xx */  /*!< STM32H7B0ABIxQ, STM32H7B0IBTx, STM32H7B0RBTx, STM32H7B0VBTx, STM32H7B0ZBTx,
                                  STM32H7B0IBKxQ */
    /* #define STM32H7A3xx */  /*!< STM32H7A3IIK6, STM32H7A3IIT6, STM32H7A3NIH6, STM32H7A3RIT6, STM32H7A3VIH6,
                                  STM32H7A3VIT6, STM32H7A3ZIT6 */
    /* #define STM32H7A3xxQ */ /*!< STM32H7A3QIY6Q, STM32H7A3IIK6Q, STM32H7A3IIT6Q, STM32H7A3LIH6Q, STM32H7A3VIH6Q,
                                  STM32H7A3VIT6Q, STM32H7A3AII6Q, STM32H7A3ZIT6Q */
    /* #define STM32H7B3xx */  /*!< STM32H7B3IIK6, STM32H7B3IIT6, STM32H7B3NIH6, STM32H7B3RIT6, STM32H7B3VIH6,
                                  STM32H7B3VIT6, STM32H7B3ZIT6 */
    /* #define STM32H7B3xxQ */ /*!< STM32H7B3QIY6Q, STM32H7B3IIK6Q, STM32H7B3IIT6Q, STM32H7B3LIH6Q, STM32H7B3VIH6Q,
                                  STM32H7B3VIT6Q, STM32H7B3AII6Q, STM32H7B3ZIT6Q */
    /* #define STM32H735xx */  /*!< STM32H735AGI6, STM32H735IGK6, STM32H735RGV6, STM32H735VGT6, STM32H735VGY6,
                                  STM32H735ZGT6 Devices */
    /* #define STM32H733xx */  /*!< STM32H733VGH6, STM32H733VGT6, STM32H733ZGI6, STM32H733ZGT6, Devices */
    /* #define STM32H730xx */  /*!< STM32H730VBH6, STM32H730VBT6, STM32H730ZBT6, STM32H730ZBI6 Devices */
    /* #define STM32H730xxQ */ /*!< STM32H730IBT6Q, STM32H730ABI6Q, STM32H730IBK6Q Devices */
    /* #define STM32H725xx */  /*!< STM32H725AGI6, STM32H725IGK6, STM32H725IGT6, STM32H725RGV6, STM32H725VGT6,
                                  STM32H725VGY6, STM32H725ZGT6, STM32H725REV6, SM32H725VET6, STM32H725ZET6,
                                  STM32H725AEI6, STM32H725IET6, STM32H725IEK6  Devices */
    /* #define STM32H723xx */  /*!< STM32H723VGH6, STM32H723VGT6, STM32H723ZGI6, STM32H723ZGT6, STM32H723VET6,
                                  STM32H723VEH6, STM32H723ZET6, STM32H723ZEI6 Devices */
    #endif

/*  Tip: To avoid modifying this file each time you need to switch between these
        devices, you can define the device in your toolchain compiler preprocessor.
  */

    #if defined(DUAL_CORE) && !defined(CORE_CM4) && !defined(CORE_CM7)
        #error "Dual core device, please select CORE_CM4 or CORE_CM7"
    #endif

    #if !defined(USE_HAL_DRIVER)
    /**
     * @brief Comment the line below if you will not use the peripherals drivers.
       In this case, these drivers will not be included and the application code will
       be based on direct access to peripherals registers
       */
    /*#define USE_HAL_DRIVER */
    #endif /* USE_HAL_DRIVER */

    /**
     * @brief CMSIS Device version number V1.10.2
     */
    #define __STM32H7xx_CMSIS_DEVICE_VERSION_MAIN (0x01) /*!< [31:24] main version */
    #define __STM32H7xx_CMSIS_DEVICE_VERSION_SUB1 (0x0A) /*!< [23:16] sub1 version */
    #define __STM32H7xx_CMSIS_DEVICE_VERSION_SUB2 (0x02) /*!< [15:8]  sub2 version */
    #define __STM32H7xx_CMSIS_DEVICE_VERSION_RC   (0x00) /*!< [7:0]  release candidate */
    #define __STM32H7xx_CMSIS_DEVICE_VERSION                                                             \
        ((__STM32H7xx_CMSIS_DEVICE_VERSION_MAIN << 24) | (__STM32H7xx_CMSIS_DEVICE_VERSION_SUB1 << 16) | \
         (__STM32H7xx_CMSIS_DEVICE_VERSION_SUB2 << 8) | (__STM32H7xx_CMSIS_DEVICE_VERSION_RC))

/**
 * @}
 */

/** @addtogroup Device_Included
 * @{
 */

#include "stm32h725xx.h"

#undef FLASH
#define FLASH ((FLASH_TypeDef*) &hwif::flashMock)
#undef PWR
#define PWR ((PWR_TypeDef*) &hwif::pwrMock)
#undef RCC
#define RCC ((RCC_TypeDef*)&hwif::rccMock)
#define SysTick ((SysTick_Type*)&hwif::sysTickMock)

namespace hwif
{
extern FLASH_TypeDef flashMock;
extern PWR_TypeDef pwrMock;
extern RCC_TypeDef rccMock;
extern SysTick_Type sysTickMock;
} // namespace hwif

/**
 * @brief General Purpose I/O
 */

/**
 * @}
 */

/** @addtogroup Exported_types
 * @{
 */
typedef enum
{
    RESET = 0,
    SET = !RESET
} FlagStatus,
    ITStatus;

typedef enum
{
    DISABLE = 0,
    ENABLE = !DISABLE
} FunctionalState;
    #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))

typedef enum
{
    SUCCESS = 0,
    ERROR = !SUCCESS
} ErrorStatus;

    /**
     * @}
     */

    /** @addtogroup Exported_macros
     * @{
     */
    #define SET_BIT(REG, BIT) ((REG) |= (BIT))

    #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))

    #define READ_BIT(REG, BIT) ((REG) & (BIT))

    #define CLEAR_REG(REG) ((REG) = (0x0))

    #define WRITE_REG(REG, VAL) ((REG) = (VAL))

    #define READ_REG(REG) ((REG))

    #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))

    #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))

    /* Use of CMSIS compiler intrinsics for register exclusive access */
    /* Atomic 32-bit register access macro to set one or several bits */
    /* Native versions are not atomic */
    #define ATOMIC_SET_BIT(REG, BIT) (SET_BIT(REG, BIT))

    /* Atomic 32-bit register access macro to clear one or several bits */
    #define ATOMIC_CLEAR_BIT(REG, BIT) (CLEAR_BIT(REG, BIT))

    /* Atomic 32-bit register access macro to clear and set one or several bits */
    #define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) (MODIFY_REG(REG, CLEARMSK, SETMASK))

    /* Atomic 16-bit register access macro to set one or several bits */
    #define ATOMIC_SETH_BIT(REG, BIT) (SET_BIT(REG, BIT))

    /* Atomic 16-bit register access macro to clear one or several bits */
    #define ATOMIC_CLEARH_BIT(REG, BIT) (CLEAR_BIT(REG, BIT))

    /* Atomic 16-bit register access macro to clear and set one or several bits */
    #define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) (MODIFY_REG(REG, CLEARMSK, SETMASK))

/**
 * @}
 */

    #if defined(USE_HAL_DRIVER)
        #include "stm32h7xx_hal.h"
    #endif /* USE_HAL_DRIVER */

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* STM32H7xx_H */
/**
 * @}
 */

/**
 * @}
 */
llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-format

EugeneZelenko commented 1 year ago

Could you please try 15 or main branch? https://godbolt.org should be helpful.

rymiel commented 1 year ago

Duplicate of #54513, fixed in clang-format 15

For extra info, the crashing line is this one:

#define __STATIC_INLINE static inline

Alongside a QualifierAlignment option.