Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

SEGV_ACCERR - Invalid Permissions for object

 
Highlighted
Naveen Sharma_1
Occasional Visitor

SEGV_ACCERR - Invalid Permissions for object

Hi,

i have this small code:

std::string getStartTime()
{
std::fstream fstrm;
std::string temp="";
return temp;
}

main()
{
std::string lastT;
lastT = getStartTime();
}

i compiled it with:
g++ -ggdb -mlp64 -lunwind testprog.cpp

when i debug it crashes at line:
"std::string temp="";" with the following error
si_code: 2 - SEGV_ACCERR - Invalid Permissions for object.

this is what i get:

Program received signal SIGSEGV, Segmentation fault
si_code: 2 - SEGV_ACCERR - Invalid Permissions for object.
std::basic_string,std::allocator >::basic_string (__a=@0x9ffffffffffff350) at basic_string.h:252
warning: Source file is more recent than library libstdc++.so.6.

252 : _Alloc(__a), _M_p(__dat) { }
(gdb) bt
#0 std::basic_string,std::allocator >::basic_string (__a=@0x9ffffffffffff350) at basic_string.h:252
#1 0x4000000000001200:0 in getStartTime () at testprog.cpp:8
#2 0x4000000000001350:0 in main () at testprog.cpp:17

this happens only when i create an object of std::fstream in function "getStartTime". if I dont create this object everything works fine.

uname -a gives this:
HP-UX jaws B.11.23 U ia64 0420832424 unlimited-user license

I have no idea whats going on. Can someone help me please?

Thanks.
3 REPLIES 3
Highlighted
Dennis Handly
Acclaimed Contributor

Re: SEGV_ACCERR - Invalid Permissions for object

What version of g++ are you using? Where did you get it?
If you have the latest from DSPP, 4.4.0-1:
http://www.hp.com/go/gcc
it mentions: gcc-help@cup.hp.com

Unless you have very large stack frames, I don't think you have a stack overflow.

Note: There is no need to initialize the string, try: std::string temp;
Highlighted
Naveen Sharma_1
Occasional Visitor

Re: SEGV_ACCERR - Invalid Permissions for object

its 4.3 or 4.4 probably, its my office server so i can confirm day after tomorrow as tomorrow is a holiday.
secondly, the initialization is deliberate to show its crashing because when i later change the string i have to do that anyway. If we see the code its a very small code but still its crashing.
i have been programming since many years but never seen this kind of thing. The interesting part is when i do this:

std::string getStartTime()
{
std::string temp="";
return temp;
}

it works fine!!!! :(
Highlighted
Dennis Handly
Acclaimed Contributor

Re: SEGV_ACCERR - Invalid Permissions for object

I have no problems with 4.2.1 and 4.4.0.

I'm not sure if this would make a difference:
std::string temp("");