0

我在 Eclipse 中遇到了一个奇怪的 C 问题。右键单击我的项目,我转到属性、C/C++ 构建、设置、Gcc C 编译器方言。在下拉菜单中,默认情况下,语言标准下没有任何内容,我的程序运行良好。但是,通过更改为其他任何内容(C90、C99 或 C11),程序在运行时会崩溃。

使用调试器,我查看了反汇编,并在某个内存地址收到了关于 strln() 的投诉,但我不确定从哪里开始。

这是一些组装:

mov (%ecx),%al
add $0x1,%ecx
test %al,%al
je 0x75234434 <strlen+97>
test $0x3,%ecx
jne 0x752343df <strlen+12>
...

有趣的是,在没有指定方言的情况下,单击杂项并单击支持 ANSI 程序 (-ansi) 会导致完全相同的错误。

欢迎任何和所有的建议:)

按要求跟踪簿:

#0  0x752343df in strlen () from C:\WINDOWS\syswow64\msvcrt.dll
#1  0x0044e2bd in __mingw_pformat ()
#2  0x0044ca5f in __mingw_vfprintf ()
#3  0x00417156 in fprintf (__stream=0x752c2980 <msvcrt!_iob+128>, __format=0x4561dc <__register_frame_info+4547036> "%s %.2lf %s %.0lf %.0lf %.2lf %.2lf %.2lf %.2lf ") at c:/mingw/include/stdio.h:246
#4  0x00418893 in skriv_v_profil (tag=0x809fe8, nasta_stat=..., sign=1, variant=2) at ..\src\kortid.c:314
#5  0x00419d65 in kor_tid (tag=0x809fe8, v2=24.25, smax=452, tmax=100000) at ..\src\kortid.c:642
#6  0x00427fdb in gang_tid (tag=0x809fe8, ret_kod=2, tmax=100000, skriv_g3=0, test_finnsg3=0, t_ack=3030.5876288659802) at ..\src\gangtid.c:2617
#7  0x00403215 in kor_tag (taget=0x809fe8, lanken=0x7cc338, riktning=1, result=0x7da1f8, resflg=7) at ..\src\ttt2gtk.c:702
#8  0x00407ff7 in grenkortag (banap=0x28fd6c, grnidx=0, tagtyp=0x7e6ea0, ttpidx=0, riktn=1, resflg=7, stppl=0x0, resp=0x28fd34) at ..\src\ttt2gtk.c:2405
#9  0x004201b8 in main (argc=11, argv=0x7e1b00) at ..\src\gtb.c:991

抱歉,我错过了复制后半部分,因为窗口非常小。

4

1 回答 1

0

I believe I have found the error. One of the variables becomes -1 and highlighted in Eclipse. I have no idea about the details but I think the solution will be very specific and I'll have to find it myself. Thanks to John Bode and WhozCraig for the help, especially regarding the traceback. Life savers, thank you!

于 2014-10-08T15:00:22.547 回答