Hello, I am trying to run a code snippet of LibTorch and I am running into a segmentation fault.

Background
I am building and linking using Gradle, with *.so files created from source. The project successfully links and compiles. However, when I run my unit tests I get a segmentation fault in the destructor of what appears to be VariableVersion.

Example Failure
This is my code currently:
#include <torch/torch.h>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>

class pytorch_test : public ::testing::Test {};

TEST_F( pytorch_test , comparators ) {
  torch::Device device = torch::kCPU;
  std::cerr << "MADE IT 1" << std::endl;
  torch::Tensor tensor = torch::eye(2, device);
  std::cerr << "MADE IT 2" << std::endl;

  EXPECT_EQ(1, 1);
}

I obtain the output of both print statements, followed finally by:
*** Error in `/hdd2/code/build/exe/unitTest/debugNonOpt/unitTest': double free or corruption (!prev): 0x0000000002aa1290 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777f5)[0x7fffed4687f5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8038a)[0x7fffed47138a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fffed47558c]
/hdd2/dyna-mast/Adapt-HTAP/code/build/exe/unitTest/debugNonOpt/unitTest[0x62e351]
/usr/local/lib/libc10.so(+0x25624)[0x7ffff6f3b624]
/hdd2/code/build/exe/unitTest/debugNonOpt/unitTest[0x62e5ed]
/hdd2/code/build/exe/unitTest/debugNonOpt/unitTest[0x62d38a]
/hdd2/code/build/exe/unitTest/debugNonOpt/unitTest[0x62acf0]
/hdd2/code/build/exe/unitTest/debugNonOpt/unitTest[0x629478]
/usr/local/lib/libgmock.so(_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc+0x65)[0x7ffff794a1c1]
/usr/local/lib/libgmock.so(_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc+0x5a)[0x7ffff7944179]
/usr/local/lib/libgmock.so(_ZN7testing4Test3RunEv+0xd2)[0x7ffff79276ea]
/usr/local/lib/libgmock.so(_ZN7testing8TestInfo3RunEv+0x10a)[0x7ffff792801e]
/usr/local/lib/libgmock.so(_ZN7testing8TestCase3RunEv+0x107)[0x7ffff79286b9]
/usr/local/lib/libgmock.so(_ZN7testing8internal12UnitTestImpl11RunAllTestsEv+0x2d2)[0x7ffff792f664]
/usr/local/lib/libgmock.so(_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc+0x65)[0x7ffff794b348]
/usr/local/lib/libgmock.so(_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc+0x5a)[0x7ffff7944fad]
/usr/local/lib/libgmock.so(_ZN7testing8UnitTest3RunEv+0xc9)[0x7ffff792e1f1]
/hdd2/code/build/exe/unitTest/debugNonOpt/unitTest[0x657310]
/hdd2/code/build/exe/unitTest/debugNonOpt/unitTest[0x654d8e]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fffed411840]


Using GDB, I obtain the following backtrace:
*** Aborted at 1619133682 (unix time) try "date -d @1619133682" if you are using GNU date ***
PC: @                0x0 (unknown)
*** SIGABRT (@0x2cba000071f9) received by PID 29177 (TID 0x7f94e0d34100) from PID 29177; stack trace: ***
    @     0x7f94e01c4390 (unknown)
    @     0x7f94d617f438 gsignal
    @     0x7f94d618103a abort
    @     0x7f94d61c17fa (unknown)
    @     0x7f94d61ca38a (unknown)
    @     0x7f94d61ce58c cfree
    @           0x62e351 c10::VariableVersion::VersionCounter::~VersionCounter()
    @     0x7f94dfc94624 c10::TensorImpl::~TensorImpl()
    @           0x62e5ed c10::intrusive_ptr<>::reset_()
    @           0x62d38a c10::intrusive_ptr<>::~intrusive_ptr()
    @           0x62acf0 at::Tensor::~Tensor()
    @           0x629478 pytorch_test_comparators_Test::TestBody()
    @     0x7f94e06a31c1 testing::internal::HandleSehExceptionsInMethodIfSupported<>()
    @     0x7f94e069d179 testing::internal::HandleExceptionsInMethodIfSupported<>()
    @     0x7f94e06806ea testing::Test::Run()
    @     0x7f94e068101e testing::TestInfo::Run()
    @     0x7f94e06816b9 testing::TestCase::Run()
    @     0x7f94e0688664 testing::internal::UnitTestImpl::RunAllTests()
    @     0x7f94e06a4348 testing::internal::HandleSehExceptionsInMethodIfSupported<>()
    @     0x7f94e069dfad testing::internal::HandleExceptionsInMethodIfSupported<>()
    @     0x7f94e06871f1 testing::UnitTest::Run()
    @           0x657310 RUN_ALL_TESTS()
    @           0x654d8e main
    @     0x7f94d616a840 __libc_start_main
    @           0x4249b9 _start
    @                0x0 (unknown)
Aborted

Does anyone have any suggestions? Thank you!