Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: Cannot build with clang thread sanitizer #28087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ngoldbaum opened this issue Jan 2, 2025 · 3 comments · Fixed by #28088
Closed

BUG: Cannot build with clang thread sanitizer #28087

ngoldbaum opened this issue Jan 2, 2025 · 3 comments · Fixed by #28088
Assignees

Comments

@ngoldbaum
Copy link
Member

ngoldbaum commented Jan 2, 2025

When I try to build NumPy using the Clang-19 thread sanitizer, I get the following compiler error:

  ../numpy/_core/src/npysort/highway_qsort.dispatch.cpp:15:5: error: no function template matches function template specialization 'QSort_ASIMD'
     15 |     DISPATCH_VQSORT(int32_t)
        |     ^
  ../numpy/_core/src/npysort/highway_qsort.dispatch.cpp:8:17: note: expanded from macro 'DISPATCH_VQSORT'
      8 | template<> void NPY_CPU_DISPATCH_CURFX(QSort)(TYPE *arr, intptr_t size) \
        |                 ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:155:42: note: expanded from macro 'NPY_CPU_DISPATCH_CURFX'
    155 |     #define NPY_CPU_DISPATCH_CURFX(NAME) NPY__CPU_CAT(NPY__CPU_CAT(NAME, _), NPY_MTARGETS_CURRENT)
        |                                          ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:42:28: note: expanded from macro 'NPY__CPU_CAT'
     42 | #define NPY__CPU_CAT(a, b) NPY__CPU_CAT_(a, b)
        |                            ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:41:29: note: expanded from macro 'NPY__CPU_CAT_'
     41 | #define NPY__CPU_CAT_(a, b) NPY__CPU_CAT__(a, b)
        |                             ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:40:30: note: expanded from macro 'NPY__CPU_CAT__'
     40 | #define NPY__CPU_CAT__(a, b) a ## b
        |                              ^
  <scratch space>:23:1: note: expanded from here
     23 | QSort_ASIMD
        | ^
  ../numpy/_core/src/npysort/highway_qsort.dispatch.cpp:16:5: error: no function template matches function template specialization 'QSort_ASIMD'
     16 |     DISPATCH_VQSORT(uint32_t)
        |     ^
  ../numpy/_core/src/npysort/highway_qsort.dispatch.cpp:8:17: note: expanded from macro 'DISPATCH_VQSORT'
      8 | template<> void NPY_CPU_DISPATCH_CURFX(QSort)(TYPE *arr, intptr_t size) \
        |                 ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:155:42: note: expanded from macro 'NPY_CPU_DISPATCH_CURFX'
    155 |     #define NPY_CPU_DISPATCH_CURFX(NAME) NPY__CPU_CAT(NPY__CPU_CAT(NAME, _), NPY_MTARGETS_CURRENT)
        |                                          ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:42:28: note: expanded from macro 'NPY__CPU_CAT'
     42 | #define NPY__CPU_CAT(a, b) NPY__CPU_CAT_(a, b)
        |                            ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:41:29: note: expanded from macro 'NPY__CPU_CAT_'
     41 | #define NPY__CPU_CAT_(a, b) NPY__CPU_CAT__(a, b)
        |                             ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:40:30: note: expanded from macro 'NPY__CPU_CAT__'
     40 | #define NPY__CPU_CAT__(a, b) a ## b
        |                              ^
  <scratch space>:25:1: note: expanded from here
     25 | QSort_ASIMD
        | ^
  ../numpy/_core/src/npysort/highway_qsort.dispatch.cpp:17:5: error: no function template matches function template specialization 'QSort_ASIMD'
     17 |     DISPATCH_VQSORT(int64_t)
        |     ^
  ../numpy/_core/src/npysort/highway_qsort.dispatch.cpp:8:17: note: expanded from macro 'DISPATCH_VQSORT'
      8 | template<> void NPY_CPU_DISPATCH_CURFX(QSort)(TYPE *arr, intptr_t size) \
        |                 ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:155:42: note: expanded from macro 'NPY_CPU_DISPATCH_CURFX'
    155 |     #define NPY_CPU_DISPATCH_CURFX(NAME) NPY__CPU_CAT(NPY__CPU_CAT(NAME, _), NPY_MTARGETS_CURRENT)
        |                                          ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:42:28: note: expanded from macro 'NPY__CPU_CAT'
     42 | #define NPY__CPU_CAT(a, b) NPY__CPU_CAT_(a, b)
        |                            ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:41:29: note: expanded from macro 'NPY__CPU_CAT_'
     41 | #define NPY__CPU_CAT_(a, b) NPY__CPU_CAT__(a, b)
        |                             ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:40:30: note: expanded from macro 'NPY__CPU_CAT__'
     40 | #define NPY__CPU_CAT__(a, b) a ## b
        |                              ^
  <scratch space>:27:1: note: expanded from here
     27 | QSort_ASIMD
        | ^
  ../numpy/_core/src/npysort/highway_qsort.dispatch.cpp:18:5: error: no function template matches function template specialization 'QSort_ASIMD'
     18 |     DISPATCH_VQSORT(uint64_t)
        |     ^
  ../numpy/_core/src/npysort/highway_qsort.dispatch.cpp:8:17: note: expanded from macro 'DISPATCH_VQSORT'
      8 | template<> void NPY_CPU_DISPATCH_CURFX(QSort)(TYPE *arr, intptr_t size) \
        |                 ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:155:42: note: expanded from macro 'NPY_CPU_DISPATCH_CURFX'
    155 |     #define NPY_CPU_DISPATCH_CURFX(NAME) NPY__CPU_CAT(NPY__CPU_CAT(NAME, _), NPY_MTARGETS_CURRENT)
        |                                          ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:42:28: note: expanded from macro 'NPY__CPU_CAT'
     42 | #define NPY__CPU_CAT(a, b) NPY__CPU_CAT_(a, b)
        |                            ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:41:29: note: expanded from macro 'NPY__CPU_CAT_'
     41 | #define NPY__CPU_CAT_(a, b) NPY__CPU_CAT__(a, b)
        |                             ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:40:30: note: expanded from macro 'NPY__CPU_CAT__'
     40 | #define NPY__CPU_CAT__(a, b) a ## b
        |                              ^
  <scratch space>:29:1: note: expanded from here
     29 | QSort_ASIMD
        | ^
  ../numpy/_core/src/npysort/highway_qsort.dispatch.cpp:19:5: error: no function template matches function template specialization 'QSort_ASIMD'
     19 |     DISPATCH_VQSORT(double)
        |     ^
  ../numpy/_core/src/npysort/highway_qsort.dispatch.cpp:8:17: note: expanded from macro 'DISPATCH_VQSORT'
      8 | template<> void NPY_CPU_DISPATCH_CURFX(QSort)(TYPE *arr, intptr_t size) \
        |                 ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:155:42: note: expanded from macro 'NPY_CPU_DISPATCH_CURFX'
    155 |     #define NPY_CPU_DISPATCH_CURFX(NAME) NPY__CPU_CAT(NPY__CPU_CAT(NAME, _), NPY_MTARGETS_CURRENT)
        |                                          ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:42:28: note: expanded from macro 'NPY__CPU_CAT'
     42 | #define NPY__CPU_CAT(a, b) NPY__CPU_CAT_(a, b)
        |                            ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:41:29: note: expanded from macro 'NPY__CPU_CAT_'
     41 | #define NPY__CPU_CAT_(a, b) NPY__CPU_CAT__(a, b)
        |                             ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:40:30: note: expanded from macro 'NPY__CPU_CAT__'
     40 | #define NPY__CPU_CAT__(a, b) a ## b
        |                              ^
  <scratch space>:31:1: note: expanded from here
     31 | QSort_ASIMD
        | ^
  ../numpy/_core/src/npysort/highway_qsort.dispatch.cpp:20:5: error: no function template matches function template specialization 'QSort_ASIMD'
     20 |     DISPATCH_VQSORT(float)
        |     ^
  ../numpy/_core/src/npysort/highway_qsort.dispatch.cpp:8:17: note: expanded from macro 'DISPATCH_VQSORT'
      8 | template<> void NPY_CPU_DISPATCH_CURFX(QSort)(TYPE *arr, intptr_t size) \
        |                 ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:155:42: note: expanded from macro 'NPY_CPU_DISPATCH_CURFX'
    155 |     #define NPY_CPU_DISPATCH_CURFX(NAME) NPY__CPU_CAT(NPY__CPU_CAT(NAME, _), NPY_MTARGETS_CURRENT)
        |                                          ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:42:28: note: expanded from macro 'NPY__CPU_CAT'
     42 | #define NPY__CPU_CAT(a, b) NPY__CPU_CAT_(a, b)
        |                            ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:41:29: note: expanded from macro 'NPY__CPU_CAT_'
     41 | #define NPY__CPU_CAT_(a, b) NPY__CPU_CAT__(a, b)
        |                             ^
  /Users/goldbaum/Documents/numpy/build/meson_cpu/npy_cpu_dispatch_config.h:40:30: note: expanded from macro 'NPY__CPU_CAT__'
     40 | #define NPY__CPU_CAT__(a, b) a ## b
        |                              ^
  <scratch space>:33:1: note: expanded from here
     33 | QSort_ASIMD
        | ^
  6 errors generated.

This seems similar to other issues we've seen where highway didn't play nicely with address sanitizer. If I manually disable highway by defining NPY_DISABLE_HIGHWAY_SORT at compile time I get different errors about missing function template specializations.

ping @Mousius, not sure why I'm getting past the HWY_IS_TSAN check. I'm building numpy on my Mac with clang-19 installed via homebrew:

$ CC=/opt/homebrew/opt/llvm/bin/clang CXX=/opt/homebrew/opt/llvm/bin/clang++ spin build --clean -- -Dbuildtype=debug -Db_sanitize=thread
@Mousius
Copy link
Member

Mousius commented Jan 2, 2025

@ngoldbaum looks like we've gotten out of sync with Highway's shared-inl.h again. I've raised google/highway#2421 to split the constant so we can check VQSORT_COMPILER_COMPATIBLE instead.

Can you try using the value of that macro in place of NPY_DISABLE_HIGHWAY_SORT for now?

@ngoldbaum
Copy link
Member Author

Can you try using the value of that macro in place of NPY_DISABLE_HIGHWAY_SORT for now?

Feeling a little dense - can you spell out a little more what I need to do?

@ngoldbaum
Copy link
Member Author

can you spell out a little more what I need to do?

Figured it out, I'll send in a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants