j**t 发帖数: 439 | 1 已经一天了,真的要疯掉了.好象是个很小的问题,可就是通不过.
double ent,dd;
Node* pHashList;
pCurSV=....; //此处略去
pHashList=pCurSV->hashList;
maxNodes=pCurSV->maxNodes;
for (i=0;i
{
ent=pHashList[i]->value; //value is a double
dd=ent+1;
printf("outcom =%f\n",i)
}
每次到i=5后,就出错.Segmentation Fault.
去掉dd=ent+1那一行, 则顺利通过.
真是奇怪极了.
OS is SunOS 5.7 Generic_106541-08 sun4u sparc SUNW,Ultra-60
可能和浮点运算有关.哪位大侠指点一下? | G**T 发帖数: 388 | 2 not sure ur problem. but ..
what is pHashList[i]?
the ith hash list's point?
what's the definition of object pHashList?
I think the problem maybe here.
【在 j**t 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 已经一天了,真的要疯掉了.好象是个很小的问题,可就是通不过. : double ent,dd; : Node* pHashList; : pCurSV=....; //此处略去 : pHashList=pCurSV->hashList; : maxNodes=pCurSV->maxNodes; : for (i=0;i: { : ent=pHashList[i]->value; //value is a double : dd=ent+1;
| w******r 发帖数: 55 | 3 it does not mean anything wrong with "dd=ent+1" here.
the segmentation error may occur before that line, most
likely your pointer
manipulations. you'd better to make sure your array does
not go out of bounds, no invalid objects in that array, or
even something already went wrong in codes other than this
piece!
use jdb or xxjdb to monitor the memeory behaviors.
segmentation faults do drive people crazy.
【在 j**t 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 已经一天了,真的要疯掉了.好象是个很小的问题,可就是通不过. : double ent,dd; : Node* pHashList; : pCurSV=....; //此处略去 : pHashList=pCurSV->hashList; : maxNodes=pCurSV->maxNodes; : for (i=0;i: { : ent=pHashList[i]->value; //value is a double : dd=ent+1;
| o**a 发帖数: 86 | 4 the pHashList[i] looks weird !
can you make sure Nodes are organized as a array ?
it seems more like a link list to me by its name.
so you can't cite with [] unless it's been overloaded.
在 jjtt (行者) 的大作中提到: 】 | s******s 发帖数: 35 | 5 I guess it is the type of i is int while printf try to
acces a float type, whihc casue the access violaion.
so try to change printf("outcom=%d\n",i);
just guess.
【在 o**a 的大作中提到】![](/moin_static193/solenoid/img/up.png) : the pHashList[i] looks weird ! : can you make sure Nodes are organized as a array ? : it seems more like a link list to me by its name. : so you can't cite with [] unless it's been overloaded. : 在 jjtt (行者) 的大作中提到: 】
| t****n 发帖数: 1347 | 6 Ding!
I think this is the right answer.
【在 s******s 的大作中提到】![](/moin_static193/solenoid/img/up.png) : I guess it is the type of i is int while printf try to : acces a float type, whihc casue the access violaion. : so try to change printf("outcom=%d\n",i); : just guess.
|
|