坚持一个奇怪的核心(C代码) - 请帮助。 [英] Stuck with a strange core (C code) -- Please help.

查看:59
本文介绍了坚持一个奇怪的核心(C代码) - 请帮助。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我在运行应用程序时多次点击此核心(编码为

in C)

在BSD OS上运行。使用gdb进入核心,它显示:


.....

(gdb)bt

#0 0x8541fa3在mTimerQUnlink(t = 0xd7f5a51,head = 0x8fec13c)

at ../../rsvp/eventwheel.c:160

#1 0x854288d in mTimerInsert(t = 0xd7f5a51 ,

callback = 0x873ce88< retran_unacked>,param = 0xd7f5a01,time = 50,

type = 1)

at ../。 ./rsvp/eventwheel.c:536

#2 0x873d266在retran_unacked(unacked_cb = 0xd7f5a00)

at ../../ rsvp / rrrmsgi3.c:1425

....

注意unacketd_cb的地址(0xd7f5a00)。 (

结构的指针)
级别2的
作为param传递给mTimerInsert的函数。但是

" param"变为0xd7f5a01(在末尾添加了1)。所有

后续处理都是基于这个错误的地址导致核心。

应用程序使用带有-O2的gcc进行编译。以及其他一些

选项。


我知道这里的地址不能以ood号码开头。这是一个已经问好的

问题。在gdb中用bt命令显示的堆栈似乎是完整的。


任何人都知道我应该选择哪个方向来解决问题?


非常感谢


-SZ

解决方案

SZ写道:



我在BSD OS上运行一个运行应用程序(在C中编码的
)时多次点击这个核心。使用gdb进入核心,它显示:

....
(gdb)bt
#0 0x8541fa3 in mTimerQUnlink(t = 0xd7f5a51,head = 0x8fec13c)
at ../../rsvp/eventwheel.c:160
#1 0x854288d in mTimerInsert(t = 0xd7f5a51,
callback = 0x873ce88< retran_unacked>,param = 0xd7f5a01,time = 50,
type = 1)
at ../../rsvp/eventwheel.c:536
#2 0x873d266 in retran_unacked(unacked_cb = 0xd7f5a00)
at ../ .. /rsvp/rrrmsgi3.c:1425
...

请注意unacketd_cb的地址(0xd7f5a00)。 (级别2的指针)
级别2被传递给mTimerInsert的函数作为param。但是
param变为0xd7f5a01(在末尾添加了1)。所有
后续处理都是基于这个错误的地址导致核心。
应用程序使用带有-O2的gcc进行编译。以及其他一些
选项。

我知道这里的地址不能以ood号码开头。这是一个既定的问题。在gdb中用bt命令显示的堆栈似乎是完整的。

任何人都知道我应该选择哪个方向进行故障排除?




对于系统或应用程序特定的新闻组或邮件列表,

,例如,如果这不是您自己的代码。

您没有向我们提供C代码,更不用说最小的例子。

这是你自己做的东西吗?结构

是什么样的?这个函数叫什么? ...


这可能很容易发现错误 - 但不是没有来源。

优质水晶球不便宜。 />
干杯

Michael

-

电子邮件:我的是/ at / gmx / dot / de地址。


如果我这样做:


void foo(struct foo * p)

{

char * a =(char *)p;

a ++;

...

}


我递增一个地址。


有两个问题出现:

1:

你传递了一个错误的参数或例程是

期望一个char指针在例程的

代码中递增

2 :

某处存在内存覆盖。


程序:


遵循被调用的例程(在汇编程序中如果你做了

没有来源)并看看在哪里被更改


jacob


谢谢,雅各布,你的回复。


故意在C代码中没有增加地址。这是

也不是char *。由于结构至少有40个字节,因此增加它会导致更大的b / b



注意:相同的例程正在多次运行并且问题
每次都不会发生
。我有源代码可用。我已经多次检查了源代码的
,并没有找到任何地址故意改为

在传递给下一个函数之前。


所以,我倾向于认为这是某种类型的内存违规。我曾经在相关例程中添加了

断言来捕获ood(坏)指针,但是它好像是b $ b然后似乎在其他地方核心。


我不知道是否有一种很好的方法来捕获这种内存违规。如果有人知道如何抓住它,那么

会欣赏它。


再次感谢


-SZ

jacob navia< ja *** @ jacob.remcomp.fr>在留言新闻中写道:< 41 ********************** @ news.wanadoo.fr> ...

如果我做:

void foo(struct foo * p)
{*> char * a =(char *)p;
a ++;
...
}

我递增一个地址。

两个问题出现在视图中:
1:
你传递了错误的参数或者例程是期望一个char指针在例程的代码中递增
2:
在某处有一个内存覆盖。

程序:

遵循被调用的例程(如果你没有源代码,则使用汇编程序)并查看更改的位置

jacob



Hi,

I''ve hit this core multiple times when running an application (coded
in C)
running on BSD OS. Using gdb getting to the core, it shows:

.....
(gdb) bt
#0 0x8541fa3 in mTimerQUnlink (t=0xd7f5a51, head=0x8fec13c)
at ../../rsvp/eventwheel.c:160
#1 0x854288d in mTimerInsert (t=0xd7f5a51,
callback=0x873ce88 <retran_unacked>, param=0xd7f5a01, time=50,
type=1)
at ../../rsvp/eventwheel.c:536
#2 0x873d266 in retran_unacked (unacked_cb=0xd7f5a00)
at ../../rsvp/rrrmsgi3.c:1425
....
Notice that the address (0xd7f5a00) of "unacketd_cb" (pointer of a
struct)
at level 2 is passed to the function of mTimerInsert as "param". But
"param" becomes 0xd7f5a01 (which added a "1" at the end). All the
subsequent processing is based on this wrong address causing the core.
The application is compiled with gcc with "-O2" along with some other
options.

I know address here can not start with ood number. This is a weired
problem. The stack shown with bt command in gdb seems to be complete.

Anyone knows what direction should I go with for the trouble shooting?

Thanks a lot

-SZ

解决方案

SZ wrote:

Hi,

I''ve hit this core multiple times when running an application (coded
in C)
running on BSD OS. Using gdb getting to the core, it shows:

....
(gdb) bt
#0 0x8541fa3 in mTimerQUnlink (t=0xd7f5a51, head=0x8fec13c)
at ../../rsvp/eventwheel.c:160
#1 0x854288d in mTimerInsert (t=0xd7f5a51,
callback=0x873ce88 <retran_unacked>, param=0xd7f5a01, time=50,
type=1)
at ../../rsvp/eventwheel.c:536
#2 0x873d266 in retran_unacked (unacked_cb=0xd7f5a00)
at ../../rsvp/rrrmsgi3.c:1425
...
Notice that the address (0xd7f5a00) of "unacketd_cb" (pointer of a
struct)
at level 2 is passed to the function of mTimerInsert as "param". But
"param" becomes 0xd7f5a01 (which added a "1" at the end). All the
subsequent processing is based on this wrong address causing the core.
The application is compiled with gcc with "-O2" along with some other
options.

I know address here can not start with ood number. This is a weired
problem. The stack shown with bt command in gdb seems to be complete.

Anyone knows what direction should I go with for the trouble shooting?



Towards a system or application specific newsgroup or mailing list,
for example, if this is not your own code.
You did not provide us with C code, let alone a minimal example.
Is it something you cooked up yourself? What does the structure
look like? What the function call? ...

It may be an easy to spot error -- but not without source.
Quality crystal balls don''t come cheap.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.


If I do:

void foo(struct foo *p)
{
char *a = (char *)p;
a++;
...
}

I increment by one the address.

Two problems spring into view:
1:
You are passing a wrong parameter or the routine is
expecting a char pointer that gets incremented in the
code of the routine
2:
There is a memory overwrite somewhere.

Procedure:

Follow the called routine (in assembler if you do
not have the source) and see where is being changed

jacob


Thanks, Jacob, for your response.

The address was not incremented in the C code purposely. It is
not char * either. Incrementing it would result in something much
larger since the structure has at least 40 bytes.

NOTE: the same routine is being run through multiple times and the problem
does not occur every time. I do have source code available. I''ve checked
the source code many times and did not found any where the address is purposely
changed before it gets passed to the next function.

So, I tend to believe this is memory violation of some sort. I once added
assert in the related routine to catch ood (bad) pointer, but it
then seem to core somewhere else.

I do not know if there is a good way to catch such memory violation. Would
appreciate it if anyone know a way to catch it.

Thanks again

-SZ
jacob navia <ja***@jacob.remcomp.fr> wrote in message news:<41**********************@news.wanadoo.fr>...

If I do:

void foo(struct foo *p)
{
char *a = (char *)p;
a++;
...
}

I increment by one the address.

Two problems spring into view:
1:
You are passing a wrong parameter or the routine is
expecting a char pointer that gets incremented in the
code of the routine
2:
There is a memory overwrite somewhere.

Procedure:

Follow the called routine (in assembler if you do
not have the source) and see where is being changed

jacob



这篇关于坚持一个奇怪的核心(C代码) - 请帮助。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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