Strange Exception Problem

Aug 19, 2011 at 12:23pm
Hey all. Weird problem. Before my program gets to the first line of main() it throws an exception, which is apparently handled and then everything appears to go on fine. I know it is throwing an exception because the VC++ 2008 Express debugger is saying "First-chance exception at 0x7c812afb in PhiThetaPsi.exe: 0xA1A01DB1: 0xa1a01db1."

Now, I've built a static library that I use with this project. If I get rid of all my files from the project and just leave the main() function by itself in the main file, I still see the first-chance exception - I'm not including anything and main looks like main() { while(true){} return 0;}.

Now if I remove my static library from the library dependencies (LinAlg.lib), the exception is no longer thrown.

Which leads me to think that, for some reason, the exception must be thrown when the lib is being initialised? When running my full code the debugger points me to this function in my LinAlg library - I have no idea how this function could be getting called - I have no 'globally' static variables in my library. Also if I search the entire library for getSubMatrix, it only shows up at the definition and implementation - nowhere else, so there is no way a static variable could be calling it anyway?:

1
2
3
4
5
6
7
const lap::Matrix lap::getSubMatrix(const lap::Matrix& mat, const int rowStart, const int rowEnd, const int colStart, const int colEnd){

    assert(rowStart >= 0 && colStart >= 0);
    assert(rowStart < mat.getNumRows() && colStart < mat.getNumCols());
    assert(rowEnd < mat.getNumRows() && colEnd < mat.getNumCols()); ** Debugger says exception thrown here.

....


I have absolutely no idea what is going on here. Any help would be greatly appreciated!

Thanks.

Nick.

Last edited on Aug 19, 2011 at 12:27pm
Aug 19, 2011 at 12:29pm
What does the call to lap::getSubMatrix() look like?
Aug 19, 2011 at 12:48pm
I'm sorry, I'm not sure what you mean? I can't find an explicit call to lap::getSubMatrix() anywhere?

Aug 19, 2011 at 12:58pm
I've made a little example. This is in a project by itself.

1
2
3
4
5
6
7
#include <iostream>
#include <LinAlg.h>

int main(){
	lap::Matrix a;
	return 0;
} 


Now here is the lap::Matrix constructor:

1
2
3
4
5
lap::Matrix::Matrix()
: numRows(0),
  numCols(0),
  matArray(0)
{}


Here is my debug output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
'LinAlgTester.exe': Loaded 'C:\Documents and Settings\Administrator\Desktop\LinAlg\LinAlgTester\Debug\LinAlgTester.exe', Symbols loaded.
'LinAlgTester.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
'LinAlgTester.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
'LinAlgTester.exe': Loaded 'C:\Documents and Settings\Administrator\Desktop\LinAlg\LinAlgTester\Debug\libacml_mp_dll.dll', Binary was not built with debug information.
'LinAlgTester.exe': Loaded 'C:\Documents and Settings\Administrator\Desktop\LinAlg\LinAlgTester\Debug\libifcoremd.dll', Binary was not built with debug information.
'LinAlgTester.exe': Loaded 'C:\Documents and Settings\Administrator\Desktop\LinAlg\LinAlgTester\Debug\libmmd.dll', Binary was not built with debug information.
'LinAlgTester.exe': Loaded 'C:\WINDOWS\system32\imagehlp.dll'
'LinAlgTester.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll'
'LinAlgTester.exe': Loaded 'C:\Documents and Settings\Administrator\Desktop\LinAlg\LinAlgTester\Debug\libiomp5md.dll'
'LinAlgTester.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_31a54e43\msvcr90.dll'
'LinAlgTester.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcp90d.dll'
'LinAlgTester.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcr90d.dll'
First-chance exception at 0x7c812afb in LinAlgTester.exe: 0xA1A01DB1: 0xa1a01db1.
First-chance exception at 0x7c812afb in LinAlgTester.exe: 0xA1A01DB2: 0xa1a01db2.
The program '[4968] LinAlgTester.exe: Native' has exited with code 0 (0x0).


Here is the call stack at the time when the first exception is thrown:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

>	kernel32.dll!7c812afb() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	
 	kernel32.dll!7c812afb() 	
 	kernel32.dll!7c812e9f() 	
 	libifcoremd.dll!0046e2f9() 	
 	libiomp5md.dll!0036c6fe() 	
 	libiomp5md.dll!0036c691() 	
 	libiomp5md.dll!00394a2d() 	
 	ntdll.dll!7c90118a() 	
 	ntdll.dll!7c91b5d2() 	
 	ntdll.dll!7c91fbdc() 	
 	ntdll.dll!7c9145d9() 	
 	ntdll.dll!7c926b30() 	
 	ntdll.dll!7c9211e4() 	
 	ntdll.dll!7c90e457() 	


Here is the call stack at the time the second exception is thrown:

1
2
3
4
5
6
7
8
9
10
11

>	kernel32.dll!7c812afb() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	
 	kernel32.dll!7c812afb() 	
 	kernel32.dll!7c80e4fc() 	
 	msvcr90d.dll!008bbf2b() 	
 	msvcr90d.dll!008bbdb1() 	
 	msvcr90d.dll!008bb9e2() 	
 	LinAlgTester.exe!__tmainCRTStartup()  Line 599	C
 	LinAlgTester.exe!mainCRTStartup()  Line 403	C
 	kernel32.dll!7c817077() 	


Further, for some reason in this example, when I break after receiving the exception, it can not take me to the getSubMatrix function, is says: "No symbols are loaded for any call stack frame. The source code cannot be displayed."

Lastly, if I change the program to:

1
2
3
4
5
6
7
#include <iostream>
#include <LinAlg.h>

int main(){
	int a = 0;
	return 0;
} 


I no longer receive any exceptions.

Haha definitely stumped me. Do you have any idea where I should be looking?

Nick.
Aug 19, 2011 at 2:59pm
What if you set a breakpoint at the start of the function? Can you see the call then?
Topic archived. No new replies allowed.