Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Build error: throw will always call terminate #1414

Open
mewmew opened this issue Apr 9, 2018 · 8 comments
Open

Build error: throw will always call terminate #1414

mewmew opened this issue Apr 9, 2018 · 8 comments

Comments

@mewmew
Copy link
Member

mewmew commented Apr 9, 2018

When trying to build nupic.core at rev 7d66fc32c65358d3759c6794c6ddb1ce7d33ab79, I received the following error message:

/home/u/Desktop/numenta_play/nupic_core_aur/src/nupic.core/src/nupic/engine/Output.cpp: In destructor ‘nupic::Output::~Output()’:
/home/u/Desktop/numenta_play/nupic_core_aur/src/nupic.core/src/nupic/engine/Output.cpp:49:36: error: throw will always call terminate() [-Werror=terminate]
   NTA_CHECK(links_.size() == 0) << "Internal error in region deletion";
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/u/Desktop/numenta_play/nupic_core_aur/src/nupic.core/src/nupic/engine/Output.cpp:49:36: note: in C++11 destructors default to noexcept
cc1plus: all warnings being treated as errors
make[2]: *** [src/CMakeFiles/nupic_core_solo.dir/build.make:1489: src/CMakeFiles/nupic_core_solo.dir/nupic/engine/Output.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:713: src/CMakeFiles/nupic_core_solo.dir/all] Error 2
make: *** [Makefile:152: all] Error 2
==> ERROR: A failure occurred in build().
@mewmew
Copy link
Member Author

mewmew commented Apr 9, 2018

Additional info:

u@x220 ~/D/n/nupic_core_aur> gcc --version
gcc (GCC) 7.3.1 20180312
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
u@x220 ~/D/n/nupic_core_aur> clang --version
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

@mewmew
Copy link
Member Author

mewmew commented Apr 9, 2018

Note, a comment states that throwing an exception from within the destructor is intended, even if "not good".

Output::~Output() {
  // If we have any outgoing links, then there has been an
  // error in the shutdown process. Not good to thow an exception
  // from a destructor, but we need to catch this error, and it
  // should never occur if nupic internal logic is correct.
  NTA_CHECK(links_.size() == 0) << "Internal error in region deletion";
  delete data_;
}

mewmew added a commit to mewpull/nupic.core that referenced this issue Apr 9, 2018
@mewmew
Copy link
Member Author

mewmew commented Apr 9, 2018

WIth -Wno-error=terminate added, the build finishes successfully.

diff --git a/CommonCompilerConfig.cmake b/CommonCompilerConfig.cmake
index a2b2a534..05eed935 100644
--- a/CommonCompilerConfig.cmake
+++ b/CommonCompilerConfig.cmake
@@ -260,8 +260,8 @@ else()
   endif()
 
   set(shared_compile_flags "${shared_compile_flags} ${stdlib_common} -fdiagnostics-show-option")
-  set (internal_compiler_warning_flags "${internal_compiler_warning_flags} -Werror -Wextra -Wreturn-type -Wunused -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers")
-  set (external_compiler_warning_flags "${external_compiler_warning_flags} -Wno-unused-variable -Wno-unused-parameter -Wno-incompatible-pointer-types -Wno-deprecated-declarations")
+  set (internal_compiler_warning_flags "${internal_compiler_warning_flags} -Werror -Wextra -Wreturn-type -Wunused -Wno-error=terminate -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers")
+  set (external_compiler_warning_flags "${external_compiler_warning_flags} -Wno-error=terminate -Wno-unused-variable -Wno-unused-parameter -Wno-incompatible-pointer-types -Wno-deprecated-declarations")
 
   CHECK_CXX_COMPILER_FLAG(-m${BITNESS} compiler_supports_machine_option)
   if (compiler_supports_machine_option)

@rhyolight
Copy link
Member

I don't know the history here. This has not been failing in any of our CI builds. What OS is this? I'm not sure adding this option is the right thing to do. @lscheinkman?

@mewmew
Copy link
Member Author

mewmew commented Apr 14, 2018

Hi Matthew,

I don't know the history here. This has not been failing in any of our CI builds. What OS is this? I'm not sure adding this option is the right thing to do. @lscheinkman?

My guess is that it has to do with never versions of GCC. My version of GCC outputs a warning (7.3.1 20180312) since an exception is thrown in a destructor, and the build is set to treat warnings as errors; thus causing the build to fail.

As for OS, I'm running Arch Linux,

u@x220 ~> uname -a
Linux x220 4.15.15-1-ARCH #1 SMP PREEMPT Sat Mar 31 23:59:25 UTC 2018 x86_64 GNU/Linux

Let me know if you require any additional information.

Cheers
/u

P.S. Thanks Matthew for putting the HTM school videos up on YouTube, they've been fun to follow.

@rhyolight
Copy link
Member

I'll keep an eye out for GCC failures like this being reported. Thanks for writing this up.

@breznak
Copy link
Member

breznak commented Jul 30, 2018

Btw, duplicate of #1000

@breznak
Copy link
Member

breznak commented Nov 24, 2018

👎 for the proposed fix with Wno-error=terminate, the culpit is in NTA_CHECK (can throw) in ~destructor! That should be solved.
There's an issue already about that topic.. #1317

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

No branches or pull requests

3 participants