Skip to content
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

Add custom assertion mechanism with backtrace printing #1610

Merged
merged 2 commits into from
Feb 25, 2017

Conversation

Praetonus
Copy link
Member

@Praetonus Praetonus commented Feb 22, 2017

This change will allow getting more complete reports from assertion failures. This will smooth the the bug report process, as users won't have to get a backtrace from a debugger. As part of this change, assertions are now enabled in release builds of the compiler, as discussed in #1553. They still are disabled in release builds of the runtime.

In the future, this system could be extended with even more precise information like line numbers. Parsing the debug information of the executables and libraries will be required for this.

Closes #1553.

PS: The tests should all fail, I've added an always firing assertion to check if the backtrace report works correctly on all systems.

@Praetonus Praetonus force-pushed the ponyassert branch 4 times, most recently from 373eca0 to 5fa5af2 Compare February 22, 2017 03:55
@Praetonus
Copy link
Member Author

The tests are failing correctly. I'll update the PR to remove the assertion.

@sylvanc
Copy link
Contributor

sylvanc commented Feb 22, 2017

Very odd: debug build on Windows is failing to find some symbols at link time.

@chalcolith
Copy link
Member

The stack trace functions are in an additional library:

diff --git a/src/libponyc/platform/vcvars.c b/src/libponyc/platform/vcvars.c
index 266f270..f9c810a 100644
--- a/src/libponyc/platform/vcvars.c
+++ b/src/libponyc/platform/vcvars.c
@@ -173,7 +173,7 @@ static bool find_kernel32(vcvars_t* vcvars, errors_t* errors)
   vcvars->ucrt[0] = '\0';
   strcpy(vcvars->default_libs,
     "kernel32.lib msvcrt.lib Ws2_32.lib advapi32.lib "
-    "vcruntime.lib legacy_stdio_definitions.lib");
+    "vcruntime.lib legacy_stdio_definitions.lib dbghelp.lib");

   strcpy(vcvars->kernel32, sdk.path);
   strcat(vcvars->kernel32, "Lib\\");

@Praetonus
Copy link
Member Author

Thanks @kulibali. I've updated the PR.

@Praetonus Praetonus force-pushed the ponyassert branch 2 times, most recently from e59c7e2 to 5f4cd0f Compare February 24, 2017 14:35
@Praetonus
Copy link
Member Author

Conflicts resolved.

This change will allow getting more complete reports from assertion
failures. This will smooth the the bug report process, as users won't
have to get a backtrace from a debugger. As part of this change,
assertions are now enabled in release builds of the compiler, as
discussed in ponylang#1553. They still are disabled in release builds of the
runtime.

In the future, this system could be extended with even more precise
information like line numbers. Parsing the debug information of the
executables and libraries will be required for this.

Closes ponylang#1553.
@Praetonus
Copy link
Member Author

And errors fixed.

@sylvanc sylvanc merged commit f2f326e into ponylang:master Feb 25, 2017
@Praetonus Praetonus deleted the ponyassert branch February 25, 2017 19:51
@jemc
Copy link
Member

jemc commented Mar 3, 2017

I'm still compiling with clang version 3.5.0 on Linux x64, and this seems to break the build for me.

In file included from src/libponyc/codegen/gendebug.cc:15:
In file included from /home/jemc/1/code/tarx/llvm-3.9.0.src.rel/build/install/include/llvm/IR/DIBuilder.h:18:
In file included from /home/jemc/1/code/tarx/llvm-3.9.0.src.rel/build/install/include/llvm/IR/DebugInfo.h:21:
In file included from /home/jemc/1/code/tarx/llvm-3.9.0.src.rel/build/install/include/llvm/ADT/SmallVector.h:29:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.3.1/../../../../include/c++/5.3.1/memory:83:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/5.3.1/../../../../include/c++/5.3.1/bits/shared_ptr_atomic.h:33:
/usr/bin/../lib/gcc/x86_64-redhat-linux/5.3.1/../../../../include/c++/5.3.1/bits/atomic_base.h:160:3: error: 
      declaration of anonymous struct must be a definition
  struct atomic_flag : public __atomic_flag_base
  ^
In file included from src/libponyc/codegen/gendebug.cc:15:
In file included from /home/jemc/1/code/tarx/llvm-3.9.0.src.rel/build/install/include/llvm/IR/DIBuilder.h:18:
In file included from /home/jemc/1/code/tarx/llvm-3.9.0.src.rel/build/install/include/llvm/IR/DebugInfo.h:23:
In file included from /home/jemc/1/code/tarx/llvm-3.9.0.src.rel/build/install/include/llvm/IR/DebugInfoMetadata.h:17:
In file included from /home/jemc/1/code/tarx/llvm-3.9.0.src.rel/build/install/include/llvm/IR/Metadata.h:26:
In file included from /home/jemc/1/code/tarx/llvm-3.9.0.src.rel/build/install/include/llvm/IR/LLVMContext.h:19:
In file included from /home/jemc/1/code/tarx/llvm-3.9.0.src.rel/build/install/include/llvm/Support/Options.h:41:
In file included from /home/jemc/1/code/tarx/llvm-3.9.0.src.rel/build/install/include/llvm/Support/CommandLine.h:29:
In file included from /home/jemc/1/code/tarx/llvm-3.9.0.src.rel/build/install/include/llvm/Support/ManagedStatic.h:18:
/usr/bin/../lib/gcc/x86_64-redhat-linux/5.3.1/../../../../include/c++/5.3.1/atomic:894:15: error: member reference
      base type 'bool' is not a structure or union
  { return __a->test_and_set(__m); }
           ~~~^ ~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-redhat-linux/5.3.1/../../../../include/c++/5.3.1/atomic:899:15: error: member reference
      base type 'volatile bool' is not a structure or union
  { return __a->test_and_set(__m); }
           ~~~^ ~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-redhat-linux/5.3.1/../../../../include/c++/5.3.1/atomic:903:8: error: member reference
      base type 'bool' is not a structure or union
  { __a->clear(__m); }
    ~~~^ ~~~~~
/usr/bin/../lib/gcc/x86_64-redhat-linux/5.3.1/../../../../include/c++/5.3.1/atomic:908:8: error: member reference
      base type 'volatile bool' is not a structure or union
  { __a->clear(__m); }
    ~~~^ ~~~~~
5 errors generated.
Makefile:654: recipe for target 'build/debug/obj/libponyc/codegen/gendebug.o' failed
make: *** [build/debug/obj/libponyc/codegen/gendebug.o] Error 1

@Praetonus
Copy link
Member Author

I guess putting a define on atomic_flag wasn't a good idea. I'll make a fix right away.

@Praetonus Praetonus mentioned this pull request Mar 3, 2017
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 this pull request may close these issues.

4 participants