[prog] Segmentation fault :-(
Sujita Purushothaman
sujita at mimos.my
Tue Sep 24 15:44:10 EST 2002
Jacinta Richardson wrote:
> Ah, right. So your program has the following:
>
> in the BaseSocket class, a type declaration along the lines of:
> int BaseSocket::Receive(unsigned char *a,int b, int c);
> and in your other script:
>
> char a[10]; /* or some value */
> /* or maybe */
> /* char *a; */
> int temp;
> /* .... */
> temp = BaseSocket::Receive(a, b, c);
>
> and it's segfaulting at the call to BaseSocket::Receive(). I'm so
> frustrated because I know that I've seen this kind of problem before. Can
> you give us more code. Perhaps the function that calls Receive, and
> the function declaration?
>
Sure.
The main program runs like this :
if (GetStatus() != SOCK_HS_SUCCESS)
return BaseSocket::Receive(data, dataLen, flags);
And the declaration for Receive is :
int BaseSocket::Receive(unsigned char *buff, int len, int flags)
{
return recv(sd, buff, len, flags);
}
(I hate functions that do nothing but call other functions!!)
recv is a standard SSL function, I think?
Execution doesn't enter BaseSocket::Receive; when I put a printf
before the "return recv(sd, buff, len,flags) line, it doesn't get printed;
Segfault happens before that. And a printf just before the line
return BaseSocket::Receive(data,dataLen,flags) prints.
Could it be that calling the method Receive requires some memory
which causes the segfault? the variable 'data' is very large, about 66,000.
> Make sure you visit www.perlmonks.org then. The monastery is a great
> place to learn or improve your Perl. (So long as you can cope with RTFM
> answers if you ask FAQs (it's amazing how many people can't)).
>
Thanks!
Yes , I can cope with RTFM. :-)
RTFM is sometimes followed by where in th FM, so that's sometimes
helpful; Otherwise I go back and RTFM, and ignore the person who told me to!
:-))
Rgds,
Sujita
More information about the Programming
mailing list