Windows x64上的应用程序问题 [英] Problem with application on Windows x64

查看:92
本文介绍了Windows x64上的应用程序问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我编译了一个C应用程序(日语:
http://www.jikos.cz/jikos/japach/ )在Windows NT上的cygwin下。它

适用于所有版本的win32。当我在Windows x64上运行它时,

挂起在以下行:


strncpy(buffer2,client.host_name,MAXLINE - strlen(buffer2)) ;


问题是client.host_name,这是一个字符串。在对不同函数进行了几次嵌套调用之后,这行是

。在main,

,其中设置了client.host_name,我可以输出它就好了。当它b / b
进入这个功能时,它只是挂在那里。


这不适用于Windows x64吗? Winx64有WOW允许运行32位
应用程序。有什么我不知道的吗?


谢谢。


Patrick

Hi all,

I have compiled a C application (japach:
http://www.jikos.cz/jikos/japach/) under cygwin on Windows NT. It
works fine on all versions of win32. When I ran it on Windows x64, it
hangs on the following line:

strncpy(buffer2, client.host_name, MAXLINE - strlen(buffer2));

The problem is client.host_name, which is a string. This line is
reached after a few nested calls to different functions. In main,
where client.host_name is set, I could output it just fine. When it
gets to this function, it just hangs there.

Shouldn''t this work on Windows x64? Winx64 has WOW that allows 32-bit
applications to be run. Is there something I''m not aware of?

Thanks.

Patrick

推荐答案

P写道:
P wrote:

大家好,


我编译了C应用程序(日本:
http://www.jikos.cz / jikos / japach / )在Windows NT上的cygwin下。它

适用于所有版本的win32。当我在Windows x64上运行它时,

挂起在以下行:


strncpy(buffer2,client.host_name,MAXLINE - strlen(buffer2)) ;


问题是client.host_name,这是一个字符串。在对不同函数进行了几次嵌套调用之后,这行是

。在main,

,其中设置了client.host_name,我可以输出它就好了。当它b / b
进入这个功能时,它只是挂在那里。
Hi all,

I have compiled a C application (japach:
http://www.jikos.cz/jikos/japach/) under cygwin on Windows NT. It
works fine on all versions of win32. When I ran it on Windows x64, it
hangs on the following line:

strncpy(buffer2, client.host_name, MAXLINE - strlen(buffer2));

The problem is client.host_name, which is a string. This line is
reached after a few nested calls to different functions. In main,
where client.host_name is set, I could output it just fine. When it
gets to this function, it just hangs there.



Dunno关于32对64位问题。


As" C"那条线对我来说很奇怪。你为什么要复制它取决于当前内容的strlen?$?通常strcpy / strncpy的目标

中有垃圾。考虑一下这个垃圾是否为MAXLINE字节没有
NUL字符....你得到一个非常大的数字。

strncpy几乎是任何任务的错误工具。


-David

Dunno about the 32 vs 64 bit issue.

As "C" that line looks very odd to me. Why does what you are copying
to it depend on the strlen of the current contents?!? Often the target
of a strcpy/strncpy has garbage in it. Consider if that garbage has no
NUL characters for MAXLINE bytes.... You get a very large number.
And strncpy is the wrong tool for almost any task.

-David


文章< 11 ************* ********@m73g2000cwd.googlegroups。 com>,

P< sp ************ @ yahoo.comwrote:
In article <11*********************@m73g2000cwd.googlegroups. com>,
P <sp************@yahoo.comwrote:

> strncpy(buffer2,client.host_name,MAXLINE - strlen(buffer2));
>strncpy(buffer2, client.host_name, MAXLINE - strlen(buffer2));



strncpy()通常用于写入其第一个参数,

buffer2在这种情况下。

那时缓冲区2已初始化了吗?如果它还没有,那么当你在第三个参数中使用strlen(buffer2)时,

可以得到任何长度的东西,因为strlen()会保留

查看缓冲区2的末尾,直到碰巧找到''\0''。


如果缓冲区2确实已在此时初始化,然后

当你覆盖这些内容时,最大复制长度取决于其当前内容是什么意思?

-

重要的是要记住,在法律方面,电脑

永远不会复制,只有人类才能制作复制品。计算机给出了

命令,而非许可。只有人才能获得许可。

- Brad Templeton

strncpy() would normally be used to write into its first argument,
buffer2 in this case.

Has buffer2 been initialized at that point? If it has not been,
then when you take strlen(buffer2) in the third parameter, you
could get just about anything for the length as strlen() will keep
looking past the end of buffer2 until it happens to find a ''\0''.

If buffer2 has indeed been initialized at that point, then
what is the point of making the maximum copying length dependant
on its current contents, when you are overwriting those contents?
--
"It is important to remember that when it comes to law, computers
never make copies, only human beings make copies. Computers are given
commands, not permission. Only people can be given permission."
-- Brad Templeton




Walter Roberson写道:

Walter Roberson wrote:

文章< 11 ********************* @ m73g2000cwd.googlegroups。 com>,

P< sp ************ @ yahoo.comwrote:
In article <11*********************@m73g2000cwd.googlegroups. com>,
P <sp************@yahoo.comwrote:

strncpy( buffer2,client.host_name,MAXLINE - strlen(buffer2));
strncpy(buffer2, client.host_name, MAXLINE - strlen(buffer2));



strncpy()通常用于写入其第一个参数,

buffer2在这种情况下。

那时缓冲区2已初始化了吗?如果它还没有,那么当你在第三个参数中使用strlen(buffer2)时,

可以得到任何长度的东西,因为strlen()会保留

查看缓冲区2的末尾,直到碰巧找到''\0''。


如果缓冲区2确实已在此时初始化,然后

当你覆盖这些内容时,最大复制长度取决于其当前内容是什么意思?

-

重要的是要记住,在法律方面,电脑

永远不会复制,只有人类才能制作复制品。计算机给出了

命令,而非许可。只有人才能获得许可。

- Brad Templeton


strncpy() would normally be used to write into its first argument,
buffer2 in this case.

Has buffer2 been initialized at that point? If it has not been,
then when you take strlen(buffer2) in the third parameter, you
could get just about anything for the length as strlen() will keep
looking past the end of buffer2 until it happens to find a ''\0''.

If buffer2 has indeed been initialized at that point, then
what is the point of making the maximum copying length dependant
on its current contents, when you are overwriting those contents?
--
"It is important to remember that when it comes to law, computers
never make copies, only human beings make copies. Computers are given
commands, not permission. Only people can be given permission."
-- Brad Templeton



我不确定开发人员的意图是什么。上面几行

,就是这样:


strcpy(buffer2,"");


因此strlen(buffer2)在它挂起的语句时为0。

这不应该导致应用程序挂起,是吗?

Patrick

I''m not sure what the intend of the developer was. A few lines above
that, there''s this:

strcpy(buffer2, "");

So strlen(buffer2) is 0 when it gets to that statement where it hangs.
This shouldn''t cause the app to hang, should it?

Patrick


这篇关于Windows x64上的应用程序问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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