作者Japie (Japie)
看板EE_DSnP
标题[问题] cannot access mem??
时间Fri Jan 13 11:35:19 2012
下面是gdb资讯
=====
(gdb) p c->getFanIn2()
$41 = (CirGate *) 0x6377a0
//c是个CirGate* 其中c的getFanIn2是有东西,也是CirGate*,
而两者都不是UndefGate
isUndef是CirGate中的virtual fun
(gdb) p c->getFanIn2()->isUndef
$40 = {bool (const CirGate * const)} 0x40fdf2 <CirGate::isUndef() const>
(gdb) p c->isUndef
$43 = {bool (const CirGate * const)} 0x40fdf2 <CirGate::isUndef() const>
(gdb) p (c->getFanIn2()->isUndef)()
Cannot access memory at address 0xb0
(gdb) p c->isUndef()
$44 = false
(gdb) p (c->getFanIn2())->isUndef()
Cannot access memory at address 0xb0
====
我想询问造成黄字和红色部份结果不同的原因>"<
在做sweep时候 必须要把要删掉的gate的fanin和fanout 连结一起删掉
但是每次一写到
c->getFanIn2()->xxxfunction()时候
根本就没有跳进xxxfunction里面(再最一开始cout东西 没有印出来)就直接segfault了...
但是xxxfunction有些又可以用 (在gdb里面印getID()是可以的)
是因为virtual与否的关系吗?
请问这边应该要怎麽写或是检查哪边呢...."orz
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.25.108
※ 编辑: Japie 来自: 140.112.25.108 (01/13 11:43)
1F:推 yangjiunru:黄色的pointer是指到CirGate::isUndef() 01/13 12:48
2F:→ yangjiunru:红色的0xb0是你的c->getFanIn2()是NULL的关系 01/13 12:48
3F:→ yangjiunru:可以在c->getFanIn2()->xxxfunction()之前加上 01/13 12:49
4F:→ yangjiunru:assert(c->getFanIn2() != NULL) 01/13 12:49
5F:→ Japie:我在前面有加上if(c->getFanIn2()) 而且把图画出来(p.8)的确 01/13 13:37
6F:→ Japie:不应该是NULL 另外c->getFanIn2->getID()可以看到4....."orz 01/13 13:39
7F:→ wmin0:有可能不小心call了 delete c->getFanIn2() 之类的东西 01/13 14:20
8F:→ wmin0:造成那边被砍掉 这边pointer没改成NULL 01/13 14:20
9F:→ wmin0:getID() 拿得到只是因为刚好的吧我想@@" 01/13 14:22
10F:→ wmin0:黄字丢出来的是function pointer的位置这样 01/13 14:23
11F:推 yangjiunru:用valgrind测是不是读到delete过的地方 01/13 14:36
12F:推 ric2k1:你是用自己的 cir 吗? 01/13 18:04
13F:推 ric2k1:直接呼叫 p c->getFanIn2()->isUndef() 呢? 01/13 18:06
14F:→ Japie:我是用自己的cir 直接那样会一样显示cannot access memory.. 01/13 19:34
15F:推 ric2k1:Oh, 你也可以 p* c->getFanin2() 看看里面的内容是不是 01/13 21:17
16F:→ ric2k1:garbage, 像是 data members 的值是否正常, vptr 是否正确 01/13 21:18
17F:→ Japie:找到问题了 真的是不小心delete掉...谢谢教授和大家m(_ _)m 01/14 13:17