Skip to content

Crash when evaluating Stockfish NNUE #8

@Stefan-Mada

Description

@Stefan-Mada

This is using the splicer build.
I tried running supervec on the .ll file generated from the evaluate_nnue function in Stockfish, but supervec crashes.

In order to isolate the bug, I ran creduce on the src/nnue/evaluate_nnue.cpp file after I prepocessed it. From the src directory of Stockfish, I ran the following command:
clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -m64 -DUSE_PTHREADS -DNDEBUG -O3 -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -flto -E -o errorTestPP.cpp nnue/evaluate_nnue.cpp

Then, I created the following bash script titled errorScript.sh which I placed in the src directory of Stockfish:

#!/bin/bash

! clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17  -pedantic -Wextra -Wshadow -m64 -DUSE_PTHREADS -DNDEBUG -O3 -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -flto   -c -S -emit-llvm -o - -w errorTestPP.cpp | timeout 3s $HOME/llvm/build/bin/opt -enable-new-pm=0 -load $HOME/minotaur/build/minotaur.so -so -S -

After creduce, I got the following source file:

class a {
public:
  a(char *, const int & = int());
} b("");

Compiled using:
clang++ errorTestPP.cpp -S -emit-llvm -o errorTestPP.ll

Called supervec using:
$HOME/llvm/build/bin/opt -enable-new-pm=0 -load $HOME/minotaur/build/minotaur.so -so -S errorTestPP.ll

Sketches output:

---------Sketches------------
(copy reservedconst)
-----------------------------
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/stefan/llvm/build/bin/opt -enable-new-pm=0 -load /home/stefan/minotaur/build/minotaur.so -so -S errorTestPP.ll
1.	Running pass 'Function Pass Manager' on module 'errorTestPP.ll'.
2.	Running pass 'Superoptimizer' on function '@__cxx_global_var_init'
 #0 0x00007fcd566015e1 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/stefan/llvm/llvm/lib/Support/Unix/Signals.inc:569:3
 #1 0x00007fcd565feed4 llvm::sys::RunSignalHandlers() /home/stefan/llvm/llvm/lib/Support/Signals.cpp:97:20
 #2 0x00007fcd565ffd05 SignalHandler(int) /home/stefan/llvm/llvm/lib/Support/Unix/Signals.inc:397:31
 #3 0x00007fcd56056210 (/lib/x86_64-linux-gnu/libc.so.6+0x46210)
 #4 0x00007fcd5682c028 llvm::DataLayout::getStructLayout(llvm::StructType*) const /home/stefan/llvm/llvm/lib/IR/DataLayout.cpp:677:8
 #5 0x00007fcd5682b713 llvm::SmallVectorTemplateCommon<llvm::LayoutAlignElem, void>::operator[](unsigned long) const /home/stefan/llvm/llvm/include/llvm/ADT/SmallVector.h:281:5
 #6 0x00007fcd5682b713 llvm::DataLayout::getAlignment(llvm::Type*, bool) const /home/stefan/llvm/llvm/lib/IR/DataLayout.cpp:765:57
 #7 0x00007fcd5682c802 llvm::Align::value() const /home/stefan/llvm/llvm/include/llvm/Support/Alignment.h:85:50
 #8 0x00007fcd5682c802 llvm::DataLayout::getABITypeAlignment(llvm::Type*) const /home/stefan/llvm/llvm/lib/IR/DataLayout.cpp:823:35
 #9 0x00007fcd54ee9384 llvm::DataLayout::getTypeAllocSize(llvm::Type*) const (/home/stefan/minotaur/build/minotaur.so+0x13d384)
#10 0x00007fcd54ee81eb llvm_util::get_operand(llvm::Value*, std::function<IR::Value* (llvm::ConstantExpr*)>, std::function<IR::Value* (IR::AggregateValue*)>) (/home/stefan/minotaur/build/minotaur.so+0x13c1eb)
#11 0x00007fcd54ed5417 (anonymous namespace)::llvm2alive_::visitCallInst(llvm::CallInst&, bool) llvm2alive.cpp:0:0
#12 0x00007fcd54edbdc7 llvm::InstVisitor<(anonymous namespace)::llvm2alive_, std::unique_ptr<IR::Instr, std::default_delete<IR::Instr> > >::visit(llvm::Instruction&) llvm2alive.cpp:0:0
#13 0x00007fcd54edfee0 (anonymous namespace)::llvm2alive_::run() llvm2alive.cpp:0:0
#14 0x00007fcd54ee118e llvm_util::llvm2alive(llvm::Function&, llvm::TargetLibraryInfo const&, std::vector<std::basic_string_view<char, std::char_traits<char> >, std::allocator<std::basic_string_view<char, std::char_traits<char> > > > const&) (/home/stefan/minotaur/build/minotaur.so+0x13518e)
#15 0x00007fcd54e22ea4 std::_Vector_base<std::basic_string_view<char, std::char_traits<char> >, std::allocator<std::basic_string_view<char, std::char_traits<char> > > >::~_Vector_base() /usr/include/c++/10/bits/stl_vector.h:336:45
#16 0x00007fcd54e22ea4 std::vector<std::basic_string_view<char, std::char_traits<char> >, std::allocator<std::basic_string_view<char, std::char_traits<char> > > >::~vector() /usr/include/c++/10/bits/stl_vector.h:683:7
#17 0x00007fcd54e22ea4 minotaur::synthesize(llvm::Function&, llvm::TargetLibraryInfo*) /usr/include/c++/10/bits/stl_vector.h:678:7
#18 0x00007fcd568ff3f5 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/stefan/llvm/llvm/lib/IR/LegacyPassManager.cpp:1449:7
#19 0x00007fcd568ff639 llvm::ilist_node_impl<llvm::ilist_detail::node_options<llvm::Function, true, false, void> >::getNext() /home/stefan/llvm/llvm/include/llvm/ADT/ilist_node.h:66:66
#20 0x00007fcd568ff639 llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, true, false, void>, false, false>::operator++() /home/stefan/llvm/llvm/include/llvm/ADT/ilist_iterator.h:157:25
#21 0x00007fcd568ff639 llvm::FPPassManager::runOnModule(llvm::Module&) /home/stefan/llvm/llvm/lib/IR/LegacyPassManager.cpp:1484:22
#22 0x00007fcd569008c1 runOnModule /home/stefan/llvm/llvm/lib/IR/LegacyPassManager.cpp:1561:7
#23 0x00007fcd569008c1 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/stefan/llvm/llvm/lib/IR/LegacyPassManager.cpp:542:55
#24 0x0000564fa9b174dc main /home/stefan/llvm/llvm/tools/opt/opt.cpp:1076:20
#25 0x00007fcd560370b3 __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#26 0x0000564fa9b183be _start (/home/stefan/llvm/build/bin/opt+0x293be)
Segmentation fault (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions