免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5565 | 回复: 9
打印 上一主题 下一主题

[应用] 请教:段错误后GDB调试没有任何信息 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-04-27 17:56 |只看该作者 |倒序浏览

代码跑个一天左右,总出现段错误;用GDB跟了下,但是出错后GDB没有任何提示信息,打印堆栈信息也是空的。

程序中有些库是第三方提供的,没有加-g,自己能控制的部分都加了-g;

同时程序出错后也没有core信息,ulimit -s 1024 这些也都加过;

交流下什么情况下,段错误后GDB调试没有任何信息?

论坛徽章:
0
2 [报告]
发表于 2012-04-28 08:39 |只看该作者
CU最近很冷啊

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
3 [报告]
发表于 2012-04-28 12:58 |只看该作者
ulimit -c unlimited

会生成cordump

论坛徽章:
0
4 [报告]
发表于 2012-04-28 17:32 |只看该作者
回复 3# T-Bagwell

谢谢版主回复,这样使用也还是产生不了
   

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
5 [报告]
发表于 2012-04-28 18:05 |只看该作者
本帖最后由 T-Bagwell 于 2012-04-28 18:23 编辑

求文件系统格式
至少文件系统要保证能够写文件

举例

  1. [root@centos1 c_leard]#
  2. [root@centos1 c_leard]# ls
  3. a  test  test2.c  test.c
  4. [root@centos1 c_leard]# cat test2.c
  5. #include <stdio.h>
  6. #include <string.h>

  7. void fuck2()
  8. {
  9.         char *test = "abcdefg";
  10.         strcpy(test, "fuck");
  11. }
  12. void fuck1()
  13. {
  14.         fuck2();
  15. }
  16. void fuck ()
  17. {
  18.         fuck1();
  19. }
  20. int main()
  21. {
  22.         fuck();
  23.         return ;
  24. }
  25. [root@centos1 c_leard]# gcc test2.c -o test2
  26. [root@centos1 c_leard]# ulimit -c unlimited
  27. [root@centos1 c_leard]# ./test2
  28. Segmentation fault (core dumped)
  29. [root@centos1 c_leard]# ls
  30. a  core.2669  test  test2  test2.c  test.c
  31. [root@centos1 c_leard]# gdb -c core.2669 ./test2
  32. GNU gdb (GDB) Red Hat Enterprise Linux (7.1-29.el6)
  33. Copyright (C) 2010 Free Software Foundation, Inc.
  34. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  35. This is free software: you are free to change and redistribute it.
  36. There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
  37. and "show warranty" for details.
  38. This GDB was configured as "x86_64-redhat-linux-gnu".
  39. For bug reporting instructions, please see:
  40. <http://www.gnu.org/software/gdb/bugs/>...
  41. Reading symbols from /root/c_leard/test2...(no debugging symbols found)...done.
  42. [New Thread 2669]
  43. Missing separate debuginfo for
  44. Try: yum --disablerepo='*' --enablerepo='*-debuginfo' install /usr/lib/debug/.build-id/e3/288ac29ed63015d8781dcf763cafadd212d6c9
  45. Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
  46. Loaded symbols for /lib64/libc.so.6
  47. Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
  48. Loaded symbols for /lib64/ld-linux-x86-64.so.2
  49. Core was generated by `./test2'.
  50. Program terminated with signal 11, Segmentation fault.
  51. #0  0x00007fe797b4dd21 in memcpy () from /lib64/libc.so.6
  52. Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.7.el6.x86_64
  53. (gdb) bt
  54. #0  0x00007fe797b4dd21 in memcpy () from /lib64/libc.so.6
  55. #1  0x00000000004004ed in fuck2 ()
  56. #2  0x00000000004004fd in fuck1 ()
  57. #3  0x000000000040050d in fuck ()
  58. #4  0x000000000040051d in main ()
  59. (gdb)

复制代码

论坛徽章:
0
6 [报告]
发表于 2012-05-02 08:26 |只看该作者
回复 5# T-Bagwell


   ext3的文件系统

写个段错误的小例程,core dump会产生
在整个代码里认为的加上段错误,gdb也能提示到相应的信息
但是整个代码跑着跑着出来段错误后,就没有任何提示信息,只有
Segmentation fault

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
7 [报告]
发表于 2012-05-02 10:26 |只看该作者
highnjupt 发表于 2012-05-02 08:26
回复 5# T-Bagwell


请参考我的调试过程

论坛徽章:
0
8 [报告]
发表于 2012-05-04 10:30 |只看该作者
回复 7# T-Bagwell

core文件产生了,之前运行的时候文件系统设置成了只读的,所以一直没有产生core文件。

core文件产生提示的是在malloc里面出了问题,GDB调试信息:
  1. Program terminated with signal 11, Segmentation fault.
  2. [New process 894]
  3. [New process 922]
  4. [New process 955]
  5. [New process 892]
  6. [New process 891]
  7. [New process 895]
  8. [New process 896]
  9. [New process 916]
  10. [New process 917]
  11. [New process 918]
  12. [New process 919]
  13. [New process 923]
  14. [New process 924]
  15. [New process 926]
  16. [New process 927]
  17. [New process 949]
  18. [New process 928]
  19. [New process 971]
  20. [New process 930]
  21. [New process 978]
  22. [New process 931]
  23. [New process 983]
  24. [New process 932]
  25. [New process 984]
  26. [New process 933]
  27. [New process 1000]
  28. [New process 934]
  29. [New process 1007]
  30. [New process 936]
  31. [New process 1013]
  32. [New process 893]
  33. [New process 937]
  34. [New process 897]
  35. [New process 938]
  36. [New process 941]
  37. [New process 935]
  38. [New process 939]
  39. [New process 943]
  40. [New process 921]
  41. [New process 940]
  42. [New process 929]
  43. [New process 942]
  44. [New process 914]
  45. [New process 944]
  46. [New process 982]
  47. [New process 945]
  48. [New process 925]
  49. [New process 946]
  50. [New process 947]
  51. [New process 948]
  52. [New process 1012]
  53. [New process 950]
  54. [New process 1004]
  55. [New process 951]
  56. [New process 952]
  57. [New process 1003]
  58. [New process 953]
  59. [New process 954]
  60. [New process 1002]
  61. [New process 957]
  62. [New process 1001]
  63. [New process 958]
  64. [New process 999]
  65. [New process 959]
  66. [New process 960]
  67. [New process 998]
  68. [New process 961]
  69. [New process 997]
  70. [New process 962]
  71. [New process 996]
  72. [New process 963]
  73. [New process 995]
  74. [New process 964]
  75. [New process 965]
  76. [New process 994]
  77. [New process 966]
  78. [New process 993]
  79. [New process 967]
  80. [New process 988]
  81. [New process 968]
  82. [New process 987]
  83. [New process 986]
  84. [New process 969]
  85. [New process 985]
  86. [New process 970]
  87. [New process 981]
  88. [New process 920]
  89. [New process 980]
  90. [New process 979]
  91. [New process 977]
  92. [New process 972]
  93. [New process 976]
  94. [New process 974]
  95. [New process 975]
  96. #0  0x0043fe30 in malloc ()
  97. (gdb) bt
  98. #0  0x0043fe30 in malloc ()
  99. Cannot access memory at address 0xbe5ff09c
复制代码
暂时还没确定是项目中的那个模块出了问题
请教下版主:提示malloc的这种错误是指针越界了还是有野指针存在呢?

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
9 [报告]
发表于 2012-05-04 14:03 |只看该作者
通过你的信息看出来,你这是一个很庞大的工程。。。

malloc段错误的话,一般是你在malloc之前用内存用的不对
这个问题需要你仔细看代码了

论坛徽章:
0
10 [报告]
发表于 2012-05-05 09:08 |只看该作者
谢谢版主回复:wink:

确实是个比较大的工程,主要修改了和业务相关的一个库,其他的代码全是原有产品上移植过来,平台也有更换过
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP