C++ runtime error message is not printed in MSVC++ - c++

My C++ compiler(MSVC++ 14.2 in Windows 10) ends without printing any error message when there is a runtime error like a segmentation fault.
For example,
std::shared<Foo> foo;
auto b = foo->bar; // segmenation fault, but ends without the error message
...
The compiler does not print the error message like Segmentation fault (core dumped)
Is there a way to set the compiler to print a runtime error message?

Related

How to locate/print abort trap: 6 error in large C++ code

I have a fairly large C++ code (multiple hpp and cpp files). It compiles properly. However, when I run, I get this error:
libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: basic_string Abort trap: 6
I understand that this error indicates an out of range error on a string, but how do I know where this error occurs? Is there a way to print out the file and line number that is throwing this error? I'm not worried about solving the issue yet, just helping find the offending line.

In Crash Reporter what's the difference between an Exception Type and an Exception Code and why are there multiple codes?

In Crash Reporter
1. What's the difference between an Exception Type and an Exception Code.
2. Why are there multiple codes?
3. Where should I look to decode them?
4. How does an EXC_BREAKPOINT exception gain two error codes when INT3 doesn't look like it takes an error codes.
For example I have this one right now:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000000000000
I've done some digging ... Possibly the exception codes are listed here:
https://opensource.apple.com/source/xnu/xnu-2050.22.13/osfmk/mach/kern_return.h
Apple helpfully provide this note which says:
"Exception Codes: Processor specific information about the exception
encoded into one or more 64-bit hexadecimal numbers. Typically, this
field will not be present because the Crash Reporter parses the
exception codes to present them as a human-readable description in the
other fields."
https://developer.apple.com/library/content/technotes/tn2151/_index.html
Well sure - but it's present in my crash report log.
Maybe these are the codes Intel describe here:
"An exception is an event that typically occurs when an instruction
causes an error. For example, an attempt to divide by zero generates
an exception. However, some exceptions, such as breakpoints, occur
under other condi- tions. Some types of exceptions may provide error
codes. An error code reports additional information about the error.
An example of the notation used to show an exception and error code is
shown below: #PF(fault code)
But Vol 2A 3-471 of the Intel processor manual says that the breakpoint exception doesn't take a fault code.
So I'm lost.

access violation run-time error for pointer assignment using Intel Fortran 2017

PROGRAM TEST
REAL(8),POINTER :: Table(:)
REAL(8) tbl_tmp(99)
ALLOCATE(Table(3))
tbl_tmp = 1.0
Table = tbl_tmp
......
WRITE(*,*) "Something here"
END PROGRAM TEST
I have an issue when i tried to compile/run an old code with the Intel Fortran 2017 compiler. The code above is an example. I have this sort of instances in an old fortran source. I know the code is written incorrectly but the whole program is huge so I don't want to modify the source.
The example above compiles and run successfully in IVF2013 but i get a run-time error when using IVF2017.
ERROR: Unhandled exception at 0x77799AAA (ntdll.dll) in test1.exe: 0xC0000374: A heap has been corrupted (parameters: 0x777D58E8).
Is there any compiler option for IVF2017 which can mimic that of IVF2013 to be able to run the code above succefully using IVF2017?? I really have no idea what's wrong here and hoping someone can give me insights on this.

"Debug error R6010 - abort() has been called" - How to debug?

At completely random times during runtime, my program crashes with the error in the title. The error occurs without any user inputs or indication as to why, which makes it difficult to debug. The Call Stack doesn't help either:
msvcr120d.dll!00007ffa9f8b7642() Unknown
msvcr120d.dll!00007ffa9f9e2044() Unknown
msvcr120d.dll!00007ffa9f9a8c98() Unknown
msvcp120d.dll!00007ffaa7273340() Unknown
msvcr120d.dll!00007ffa9f9baf90() Unknown
msvcr120d.dll!00007ffa9f9aafe2() Unknown
ntdll.dll!00007ffad1633573() Unknown
msvcp120d.dll!00007ffaa722df29() Unknown
msvcr120d.dll!00007ffa9f8ba105() Unknown
msvcr120d.dll!00007ffa9f8ba357() Unknown
vfbasics.dll!00007ffab17dc729() Unknown
kernel32.dll!00007ffacede13d2() Unknown
ntdll.dll!00007ffad15b5444() Unknown
According to the thread list, the error doesn't occur in the main thread, so it might be a multi-threading conflict, but I don't know for sure.
I can't post any code because the program is too big and I don't know which piece of the code is causing the issue.
How can I narrow the problem down?

Segmentation Fault: "...no such file or directory"

I'm getting weird seg fault that seems to be coming from somewhere not in my program...not explicitly anyway. I'm calling "strcmp" on two array's... Both arrays are stored in the same type of structs. I'm getting at one with dot notation and one through dereferencing with "->":
int name = strcmp(one.name, two->name);
It compiles fine but when I run it I get the seg fault. I've tried tracking it down with GDB but when I put breakpoints in just before where I think it should occur, it seg faults anyway. I'm getting:
Program received signal SIGSEGV, Segmentation fault.
__strcmp_ia32 () at ../sysdeps/i386/i686/multiarch/../strcmp.S:40
40 ../sysdeps/i386/i686/multiarch/../strcmp.S: No such file or directory.
in ../sysdeps/i386/i686/multiarch/../strcmp.S
FML. Suggestions? Thanks!
My suggestion: Compile it with -g and run it through valgrind.