malloc调用没有返回 [英] malloc call not returning

查看:80
本文介绍了malloc调用没有返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



你好,


我有问题,malloc电话没有回来。


< source-snip>

printf(" a \ n");

my_pointer =(struct_pointer)malloc(struct_size); / *尺寸1420 * /

printf(" b\ n);

< / source-snip>


我几乎可以肯定,我的程序释放了一些内存,但是如果没有内存,那么malloc应该返回一些NULL指针。


函数的正常输出是''a''和'b''。但有时候(在运行一段时间之后),程序会在打印a后停止。程序员的其他

线程仍在响应命令,但是调用malloc的那个人没有做出反应。


你在某个地方有过类似的问题吗?

编译器:Fedora Core 2上的gcc-3.3.3-7

问候语:

Norbert < br>


Hi NG,

I''ve the problem, that a malloc call is not returning.

<source-snip>

printf("a\n");
my_pointer = (struct_pointer)malloc(struct_size); /*size 1420*/
printf("b\n");
</source-snip>

I''m almost sure, that my program frees some memory, but if there is no
memory, the malloc should return some NULL-pointer.

The ''normal'' output of the function is ''a'' and ''b''. But sometimes (after
a while of running), the program stops after printing the ''a''. The other
threads of the programm are still responding to commands, but the one
who called the malloc does not reacts.

Have you somewhere had a similar problem?
Compiler: gcc-3.3.3-7 on Fedora Core 2
Greeting:
Norbert

推荐答案

Norbert Leister写道:
Norbert Leister wrote:

>

嗨NG,


我有问题,malloc电话没有返回。


< source-snip>


printf(" a \ n");

my_pointer =(struct_pointer)malloc(struct_size); / *尺寸1420 * /

printf(" b\ n);

< / source-snip>


我几乎可以肯定,我的程序释放了一些内存,但是如果没有内存,那么malloc应该返回一些NULL指针。


函数的正常输出是''a''和'b''。但有时候(在运行一段时间之后),程序会在打印a后停止。程序员的其他

线程仍在响应命令,但是调用malloc的那个人没有做出反应。


你在某个地方有过类似的问题吗?

编译器:Fedora Core 2上的gcc-3.3.3-7
>
Hi NG,

I''ve the problem, that a malloc call is not returning.

<source-snip>

printf("a\n");
my_pointer = (struct_pointer)malloc(struct_size); /*size 1420*/
printf("b\n");
</source-snip>

I''m almost sure, that my program frees some memory, but if there is no
memory, the malloc should return some NULL-pointer.

The ''normal'' output of the function is ''a'' and ''b''. But sometimes (after
a while of running), the program stops after printing the ''a''. The other
threads of the programm are still responding to commands, but the one
who called the malloc does not reacts.

Have you somewhere had a similar problem?
Compiler: gcc-3.3.3-7 on Fedora Core 2



附上你的调试器看看应用程序正在做什么。


-

Ian Collins。

Attach your debugger and see what the application is doing.

--
Ian Collins.


Ian Collins写道:
Ian Collins wrote:

附上调试器并查看应用程序正在做什么。
Attach your debugger and see what the application is doing.



它是一些远程执行的代码 - 这就是为什么我使用printf

查看代码停止的位置


问候:

Norbert

it is some remotely executed code - that''s why I''m using the printf to
see where the code is stopping

Greetings:
Norbert


文章< f1 ******* ***@anderson.hrz.tu-chemnitz.de> ;,

Norbert Leister< ma ****** @ web.dewrote:
In article <f1**********@anderson.hrz.tu-chemnitz.de>,
Norbert Leister <ma******@web.dewrote:

>我有问题,malloc调用没有返回。
>I''ve the problem, that a malloc call is not returning.



如果malloc()真的没有返回,最可能的问题是

你有一个malloc() - 相关程序中其他地方的错误

搞乱了malloc()的数据结构。


在某种内存检查工具下运行你的程序例如

valgrind。


- Richard

-

考虑应该是考虑到需要多达32个字符

在某些字母表中 - 1963年的X3.4。

If malloc() is really not returning, the most likely problem is that
you''ve got a malloc()-related error somewhere else in the program that
is messing up malloc()''s data structures.

Run your program under some kind of memory-checking tool such as
valgrind.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.


这篇关于malloc调用没有返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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