C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

unexplainable segfaults

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Marc R.
Guest





PostPosted: Mon May 21, 2007 8:53 am    Post subject: unexplainable segfaults Reply with quote



Hi there,

consider the following code:

#include "stdafx.h"
int main(int argc, char* argv[]) {
const int Xres = 600;
const int Yres = 600;
std::pair<float,float> dispFNabla[Yres][Xres];
std::pair<float,float> dispFNabla2[Yres][Xres];
std::pair<float,float> dispFNabla3[Yres][Xres];
std::pair<float,float> dispFNabla4[Yres][Xres];
std::pair<float,float> dispFNabla5[Yres][Xres];
std::pair<float,float> dispFNabla6[Yres][Xres];
std::pair<float,float> dispFNabla7[Yres][Xres];
std::pair<float,float> depthFNablaZ[Yres][Xres];
float depthHessZ[Yres][Xres][4];
return 0;
}

Why in the world could it generate a segmentation fault? :

(gdb) run
Starting program: /local/home/neo/BT/P/MicroDepth
Failed to read a valid object file image from memory.

Program received signal SIGSEGV, Segmentation fault.
0x08048e0c in main () at src/MicroDepth.cxx:6
6 std::pair<float,float> dispFNabla[Yres][Xres];
(gdb) print dispFNabla
$1 = {{{first = 0, second = 0} <repeats 600 times>} <repeats 599
times>, {{
first = 0, second = 0} <repeats 277 times>, {first =
-2.67723372e-05,
second = -1.70868349}, {first = -2.89307955e-05,
second = -2.45322353e-05}, {first = -2.6772359e-05,
<snip>
second = 1.40129846e-45}...}}
(gdb) print dispFNabla2
$2 = {{{first = 0, second = 0} <repeats 600 times>} <repeats 600
times>}
(gdb) print dispFNabla3
Cannot access memory at address 0xbf66030c
(gdb) print dispFNabla4
Cannot access memory at address 0xbf3a110c

Regards,
Marc

--
DO NOT REPLY TO THIS EMAIL ADDRESS, IT WILL NOT WORK
ACTUALLY YOU WILL AUTOMATICALLY BE BLACKLISTED
Back to top
Ian Collins
Guest





PostPosted: Mon May 21, 2007 8:59 am    Post subject: Re: unexplainable segfaults Reply with quote



Marc R. wrote:
Quote:
Hi there,

consider the following code:

#include "stdafx.h"

What's this?

Quote:
int main(int argc, char* argv[]) {
const int Xres = 600;
const int Yres = 600;
std::pair<float,float> dispFNabla[Yres][Xres];
std::pair<float,float> dispFNabla2[Yres][Xres];
std::pair<float,float> dispFNabla3[Yres][Xres];
std::pair<float,float> dispFNabla4[Yres][Xres];
std::pair<float,float> dispFNabla5[Yres][Xres];
std::pair<float,float> dispFNabla6[Yres][Xres];
std::pair<float,float> dispFNabla7[Yres][Xres];
std::pair<float,float> depthFNablaZ[Yres][Xres];
float depthHessZ[Yres][Xres][4];
return 0;
}

Why in the world could it generate a segmentation fault? :

Overflowed your stack?


--
Ian Collins.
Back to top
Default User
Guest





PostPosted: Mon May 21, 2007 9:11 am    Post subject: Re: unexplainable segfaults Reply with quote



Marc R. wrote:

Quote:
Hi there,

consider the following code:

float depthHessZ[Yres][Xres][4];

Cannot access memory at address 0xbf3a110c

Almost 1.5 meg of automatic data? I'm not surprised. Use a vector or
dynamic array.



Brian
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.