亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫
12下一頁
最近訪問板塊 發(fā)新帖
查看: 4722 | 回復(fù): 10
打印 上一主題 下一主題

epoll的奇怪問題---【已解決】 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2010-03-15 09:14 |只看該作者 |倒序?yàn)g覽
本帖最后由 banceleung 于 2010-03-15 09:50 編輯

先貼代碼后解釋 #include <pthread.h>

  1. #include <sys/epoll.h>

  2. class CNetMsgImp

  3. {

  4. public:        

  5.         struct epoll_event m_events[12];

  6.         //char temp[1000]; //-------!!!!!!!!!!!!----------        

  7.         int m_kdpfd;

  8.         CNetMsgImp();

  9.         ~CNetMsgImp();

  10. };

  11. CNetMsgImp::CNetMsgImp()

  12. {               

  13.         m_kdpfd = epoll_create(11+11);  

  14.   m_events[11].events = 11;

  15.   epoll_wait(m_kdpfd,m_events, 20, -1);   

  16. }

  17. int main(int argc, char* argv[])

  18. {               

  19.         CNetMsgImp* netMsgImg = new CNetMsgImp;        

  20. }
復(fù)制代碼
g++ -pthread -o test test.cpp
valgrind --tool=memcheck ./test


==11054== Memcheck, a memory error detector.
==11054== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==11054== Using LibVEX rev 1804, a library for dynamic binary translation.
==11054== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==11054== Using valgrind-3.3.0-Debian, a dynamic binary instrumentation framework.
==11054== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==11054== For more details, rerun with: -v
==11054==
==11054== Syscall param epoll_wait(events) points to unaddressable byte(s)
==11054==    at 0x40007F2: (within /lib/ld-2.7.so)
==11054==    by 0x8048623: main (in /mnt/hgfs/NetFrameL/test)
==11054==  Address 0x42c10bc is 0 bytes after a block of size 148 alloc'd
==11054==    at 0x4023294: operator new(unsigned) (vg_replace_malloc.c:224)
==11054==    by 0x8048615: main (in /mnt/hgfs/NetFrameL/test) #include <pthread.h>

  1. #include <sys/epoll.h>

  2. class CNetMsgImp

  3. {

  4. public:        

  5.         struct epoll_event m_events[12];        

  6.         char temp[1000];

  7.         int m_kdpfd;

  8.         CNetMsgImp();

  9.         ~CNetMsgImp();

  10. };

  11. CNetMsgImp::CNetMsgImp()

  12. {               

  13.         m_kdpfd = epoll_create(11+11);  

  14.   m_events[11].events = 11;

  15.   epoll_wait(m_kdpfd,m_events, 20, -1);   

  16. }

  17. int main(int argc, char* argv[])

  18. {        

  19.         CNetMsgImp* netMsgImg = new CNetMsgImp;        

  20. }
復(fù)制代碼
g++ -pthread -o test test.cpp
valgrind --tool=memcheck ./test


==11092== Memcheck, a memory error detector.
==11092== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==11092== Using LibVEX rev 1804, a library for dynamic binary translation.
==11092== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==11092== Using valgrind-3.3.0-Debian, a dynamic binary instrumentation framework.
==11092== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==11092== For more details, rerun with: -v
==11092==

如上,如果在類里不加那個(gè)char temp[1000];則valgrind會(huì)報(bào)錯(cuò),運(yùn)行時(shí)程序會(huì)有棧錯(cuò)誤,明確的說會(huì)侵占對(duì)象內(nèi)存,改變現(xiàn)有對(duì)象的內(nèi)部數(shù)據(jù)。
以上代碼是原有程序的簡化,已能說明問題。

  1. #include <sys/epoll.h>

  2. class A

  3. {

  4.         public:

  5.         int a;

  6.         struct epoll_event m_events[12];

  7.         //char temp[1000];

  8.         A();

  9.         ~A();

  10. };

  11. A::A()

  12. {

  13.         a = epoll_create(11+11);  

  14.         epoll_wait(a,m_events, 20, -1);   

  15. }

  16. int main(void)

  17. {

  18.         A* b = new A;

  19. }
復(fù)制代碼
來個(gè)更簡單的,問題照舊。

論壇徽章:
324
射手座
日期:2013-08-23 12:04:38射手座
日期:2013-08-23 16:18:12未羊
日期:2013-08-30 14:33:15水瓶座
日期:2013-09-02 16:44:31摩羯座
日期:2013-09-25 09:33:52雙子座
日期:2013-09-26 12:21:10金牛座
日期:2013-10-14 09:08:49申猴
日期:2013-10-16 13:09:43子鼠
日期:2013-10-17 23:23:19射手座
日期:2013-10-18 13:00:27金牛座
日期:2013-10-18 15:47:57午馬
日期:2013-10-18 21:43:38
2 [報(bào)告]
發(fā)表于 2010-03-15 09:29 |只看該作者
struct epoll_event m_events[12];

epoll_wait(a,m_events, 20, -1);

上面是12,下面是20

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2010-03-15 09:32 |只看該作者
{:3_191:},奇怪,我這里運(yùn)行沒有問題。。。
ubuntu 64bit gcc 4.33

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2010-03-15 09:36 |只看該作者
回復(fù) 2# hellioncu


       大意了大意了,多謝!

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 2010-03-15 09:39 |只看該作者
epoll_wait(a,m_events, 12, -1);

論壇徽章:
0
6 [報(bào)告]
發(fā)表于 2010-03-15 09:40 |只看該作者
[root@localhost test]# valgrind --tool=memcheck ./epoll
==18449== Memcheck, a memory error detector
==18449== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==18449== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==18449== Command: ./epoll
==18449==
==18449==
==18449== HEAP SUMMARY:
==18449==     in use at exit: 148 bytes in 1 blocks
==18449==   total heap usage: 1 allocs, 0 frees, 148 bytes allocated
==18449==
==18449== LEAK SUMMARY:
==18449==    definitely lost: 0 bytes in 0 blocks
==18449==    indirectly lost: 0 bytes in 0 blocks
==18449==      possibly lost: 0 bytes in 0 blocks
==18449==    still reachable: 148 bytes in 1 blocks
==18449==         suppressed: 0 bytes in 0 blocks
==18449== Rerun with --leak-check=full to see details of leaked memory
==18449==
==18449== For counts of detected and suppressed errors, rerun with: -v
==18449== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 15 from

論壇徽章:
0
7 [報(bào)告]
發(fā)表于 2010-03-15 09:42 |只看該作者
”hgfs/NetFrameL“
...呵呵!。 準(zhǔn)備開源么。。

論壇徽章:
0
8 [報(bào)告]
發(fā)表于 2010-03-15 09:49 |只看該作者
回復(fù) 7# peidright


    老板沒意見的話我也倒是樂意。

   vmware--tool的默認(rèn)路徑。

論壇徽章:
0
9 [報(bào)告]
發(fā)表于 2010-03-15 09:55 |只看該作者
LS正確

論壇徽章:
0
10 [報(bào)告]
發(fā)表于 2010-03-15 10:10 |只看該作者
回復(fù) 8# banceleung
搜google發(fā)現(xiàn)了。開始以為是 high speed google file system...
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP