如何调试“传递给C运行时函数的无效参数”? [英] how to debug "Invalid parameter passed to C runtime function"?

查看:558
本文介绍了如何调试“传递给C运行时函数的无效参数”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大约1TB的原始数据文件,带有相对较小的标记数据子集。我已经编写了c ++代码(调用了一些古老的MSVC ++ 2003代码,我对其进行了重大修改以使其可以在最新的编译器上进行编译)以聚合带注释的数据切片。

I've got about a terabyte of files with raw data, with a relatively small subset of labelled data. I've written c++ code (calling some ancient MSVC++2003 code I heavily modified to get it to compile on recent compilers) to aggregate the annotated data slices.

其中很大一部分标记的数据集中在一个文件中,但该文件却是我的程序崩溃的文件。

A big part of that labelled data is concentrated in one file, but that file turns out to be the one where my program crashes.

我正在获取

Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.
terminate called after throwing an instance of 'int'

实例后终止终止,窗口告诉我在弹出窗口中也是如此,但是从现在看来,要从可执行文件/调试器中获取任何有用的信息为时已晚(尽管我对Qt的调试器完全没有经验)。

In my Qt output window, and windows tells me the same in a popup, but at this point it's too late to get any useful info out of the executable / debugger it seems (though I'm not experienced at all with Qt's debugger).

我到处搜寻Google,发现很多人都收到此错误消息,但是它是如此普遍,以至于他们的问题都不会和我的一样。一遍又一遍的C运行时函数列表很慢,筛选起来很慢,而且似乎无济于事。

I've googled all over and found plenty of people with this error message but it's so generic that none of their issues could be the same as mine, and there's such a long list of different C runtime functions that sifting through all of them is slow and it doesn't seem to help.

找一个虫子,你帮他一天。教一个人调试,您将帮助他一生。发布关于stackoverflow的方法,您会帮助许多人并获得很多支持。

"Find a man a bug, and you help him for a day. Teach a man to debug and you help him for a lifetime. Post the way on stackoverflow and you help many men and get a lot of upvotes."

是否有通用方法来查找问题所在的C运行时函数以及参数是什么?我是否错过了一些高级调试器功能?还有什么您可以推荐或我可以提供的信息吗?

Is there a generic method to find what C runtime function the problem was and what the argument was? Did I miss some fancy debugger features? Is there anything else you could recommend or info I could provide?

我希望对此有一个全面的答案,以帮助所有人解决这个问题,不仅仅是我,而是我

I'd hope to get a catch-all answer to this to help everyone with this problem, not just me, but I'll be glad if I'm helped too of course.

我的堆栈跟踪如下:

0 ntdll!DbgBreakPoint 0x7727000d

1 ntdll!DbgUiRemoteBreakin 0x772ff156

2 ?? 0x6f06eaa1

3 KERNEL32!BaseThreadInitThunk 0x7501338a

4 ntdll!RtlInitializeExceptionChain 0x77299902

5 ntdll!RtlInitializeExceptionChain 0x772998d5

6 ?

0 ntdll!DbgBreakPoint 0x7727000d
1 ntdll!DbgUiRemoteBreakin 0x772ff156
2 ?? 0x6f06eaa1
3 KERNEL32!BaseThreadInitThunk 0x7501338a
4 ntdll!RtlInitializeExceptionChain 0x77299902
5 ntdll!RtlInitializeExceptionChain 0x772998d5
6 ??

和gdb似乎无法获得更好的跟踪(我尝试执行的任何操作都会使我收到超时错误)。

尝试了更多的功能之后,只是为了确保一切都尝试了 backtrace,所以超时了。再次给了我一个结果。我想我永远都不会在超时后在gdb中花那么多时间。

After trying a couple more functions just to be sure everything gave a timeout trying "backtrace" once again did give me a result. I guess I just never put this much time in gdb after it timeouting on me once.

也就是说,我可能能够通过此新信息找到一些东西。考虑到我的特定问题已经解决,但我的一般观点仍然有效:我现在已经找到了存在问题的函数(我认为),但不是为什么有问题,也不是无效参数是什么。更好的是,我将其追溯到显示 throw 1的行。因此,现在我假设Windows / Qt将其转换为无效参数。

That said, I might be able to find something with this new info. Consider my specific problem closed, but my general point is still valid I believe: I've now found the function with the problem (I think), but not why it is a problem, nor what the invalid parameter is. Even better, I've traced it to a line where it says "throw 1". So now I'm assuming windows/Qt translates that to the "invalid parameter". But it's not true.

...

#17 0x00c17d72 in libstdc ++-6!.cxa_throw()来自C:\Qt\5.5\mingw492_32\bin\libstdc ++ -6.dll
没有可用的符号表信息。
...

#17 0x00c17d72 in libstdc++-6!.cxa_throw () from C:\Qt\5.5\mingw492_32\bin\libstdc++-6.dll No symbol table info available. ...

推荐答案

就个人而言,在Linux终端上,我使用gcc进行编译,并使用gdb进行调试。要使用gcc编译带有调试选项的程序,只需要将 -g 添加到其他标志中。例如: gcc file.c -o文件-std = c99 -g 。然后,您可以键入 gdb文件,然后进入交互式调试器。除其他有用的功能外,您还可以运行程序,调用函数并插入断点。有关完整的用法的详细信息,请访问此网站- http://www.tutorialspoint.com/gnu_debugger /index.htm

Personally, on a Linux terminal, I use gcc for compiling and gdb for debugging. To compile a program with debugging options using gcc, you simply have to add a -g to your other flags. Ex:gcc file.c -o file -std=c99 -g. You can then type gdb file and you enter into an interactive debugger. Among other helpful things, you can run the program, call functions and insert breakpoints. For a full and well explained usage go to this website-http://www.tutorialspoint.com/gnu_debugger/index.htm

这篇关于如何调试“传递给C运行时函数的无效参数”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆