Re: Crash observed with object on stack but not on heap
- From: Sheth Raxit <raxitsheth2000@xxxxxxxxx>
- Date: Sat, 18 Aug 2007 23:38:29 -0700
On Aug 13, 8:13 pm, ankitmitta...@xxxxxxxxx wrote:
Hi All,Are you trying to Tokenizing String ? <are you using strtok or
We have multi-threaded application supported on linux. We are
observing very strange behavior related to crash due to this pointer
is getting null.
Let me take snapshot of code..
let us suppose we have 2 classes sample and token
inside any function..
{
sample s1;
token t1;
t1.InstanceFromToken(s1);
strtok_r or simillar.? Is the functions you are trying to use are
Thread Safe ?
there are few functions which provides following clarification in man
pages
<from man strtok_r>
If the character buffer s1 is in dynamic memory, strtok_r() is thread-
safe.
<what if s1 is on array ?, I think it is Crash/corrupted behaviour.>
Hope this helps to find out the root cause and further actions.
-Raxit
}
defenition of InstanceFromToken() looks like..
void token::InstanceFromToken(sample & s)
{
s.function();
}
we are running our servers on 24*7 env and facing crash sometimes.
gdb core stack shows that this pointer is getting null inside
function() API.
so when it tries to use any data member of s class inside function(),
application is getting crash
few strange things are
1. this pointer is getting null.
2.if we check s value inside InstanceFromToken() function, it shows
perfectly in gdb frames,all members are valid
3.This issue is very inconsistent in nature, not reproducible on all
platform like solaris, windows however same code is using there.
4. if we allocate memory of s on heap mean dynamically like sample
s1=new s1() instead of sample s1, problem is no longer reproducible
At this point we are not sure why all these things are happen and more
strangely this pointer is getting null.
Any pointer in this regard is highly usefull and would help to resolve
this issue.
.
- References:
- Crash observed with object on stack but not on heap
- From: ankitmittal14
- Crash observed with object on stack but not on heap
- Prev by Date: Re: File mod time versus system time problem.
- Next by Date: wxWidgets+OpenGL+C++. Which to use IDE?
- Previous by thread: Re: Crash observed with object on stack but not on heap
- Next by thread: Re: Crash observed with object on stack but not on heap
- Index(es):
Relevant Pages
|