avatar
悲剧,忘记用BCB了# PhotoGear - 摄影器材
d*n
1
【 以下文字转载自 Programming 讨论区 】
发信人: dryden (拽的狠-仁义礼智信), 信区: Programming
标 题: heap&stack Linux vs. Windows
发信站: BBS 未名空间站 (Fri Sep 14 13:29:51 2012, 美东)
最近才玩windows,发现windows 里面heap stack 位置不
太和linux一样。
一直以为win 和 Linux是一样的
欢迎讨论
thrust免进。
avatar
h*g
2
刚拍下一个LX,头脑一热
avatar
g*w
3
x86的stack,地址从高到低,这个window图肯定不对

【在 d****n 的大作中提到】
: 【 以下文字转载自 Programming 讨论区 】
: 发信人: dryden (拽的狠-仁义礼智信), 信区: Programming
: 标 题: heap&stack Linux vs. Windows
: 发信站: BBS 未名空间站 (Fri Sep 14 13:29:51 2012, 美东)
: 最近才玩windows,发现windows 里面heap stack 位置不
: 太和linux一样。
: 一直以为win 和 Linux是一样的
: 欢迎讨论
: thrust免进。

avatar
j*c
4
拍的没bcb

【在 h*******g 的大作中提到】
: 刚拍下一个LX,头脑一热
avatar
d*n
5
我和你开始想的一样。但是运行后就不一样了。
不知道是不是被windows paging给搞乱了
我贴code output

【在 g**w 的大作中提到】
: x86的stack,地址从高到低,这个window图肯定不对
avatar
h*g
6
不是可以搜多DELL笔记本连到ebay然后BCB嘛,我试过buy it now的物品是可以的

【在 j****c 的大作中提到】
: 拍的没bcb
avatar
d*n
7
//in windows
#include
#include
using namespace std;
class A{
public :
int a;
int b;
};
int main()
{
cout<

int before=4;
cout<A objA;
void *p=malloc(1000);
cout<cout<cout<cout<int after=4;
cout<return 0;
}
//output from windows win32
/*
00A0119A
STACK &before=0033FD00
HEAP *p=007983E0
&objA.a0033FCF0
&objA.b0033FCF4
objA=0033FCF0
STACK &after=0033FCD8
Press any key to continue . . .
*/
avatar
c*y
8
你不是说你的LX是拍的么?那就不是buy it now咯,那就没有bcb咯

【在 h*******g 的大作中提到】
: 不是可以搜多DELL笔记本连到ebay然后BCB嘛,我试过buy it now的物品是可以的
avatar
d*n
9
//Linux 64bit
1
STACK &before=0x7fff6b620984
HEAP *p=0xa0ad010
&objA.a0x7fff6b620970
&objA.b0x7fff6b620974
objA=0x7fff6b620970
STACK &after=0x7fff6b62096c
avatar
j*c
10
你到底是bid的,还是bin的阿?

【在 h*******g 的大作中提到】
: 不是可以搜多DELL笔记本连到ebay然后BCB嘛,我试过buy it now的物品是可以的
avatar
d*n
11
stack 和 heap 高低正好调换了。
而且我也认为windows那个有点问题,stack should grow downward
高人给解释下
avatar
h*g
12
原来拍的是没BCB啊=。=那还好,本来想把shipping fee给cash back的

【在 c********y 的大作中提到】
: 你不是说你的LX是拍的么?那就不是buy it now咯,那就没有bcb咯
avatar
d*n
13
重新编译了一下,发现 x64的和win32的不一样。x64的和linux 一致。
//windows 64
000000013F4D1000
STACK &before=000000000029FB00
HEAP *p=0000000000148860
&objA.a000000000029FB10
&objA.b000000000029FB14
objA=000000000029FB10
STACK &after=000000000029FB08
Press any key to continue . . .
avatar
o*x
14
价格不错,我买的的LX成色比这个差,价格还比这个高,送去清理维护了一下,修理费
加运费又花了将近180美元。要不是喜欢宾得老机器,真是亏大了。

【在 h*******g 的大作中提到】
: 刚拍下一个LX,头脑一热
avatar
d*n
15
我上面那个图是不是 win32 only ?
avatar
h*g
16
我没贴价格啊?

【在 o*****x 的大作中提到】
: 价格不错,我买的的LX成色比这个差,价格还比这个高,送去清理维护了一下,修理费
: 加运费又花了将近180美元。要不是喜欢宾得老机器,真是亏大了。

avatar
g*w
17
I think your code couldn't tell whether stack growing downward or not. in
main() function frame, it cut enough from stack for local variable, but it's
up to compiler to assign them to variables, which order doesn't matter.
you can try this: call another function from main, in that function print
out the address of variables, they should be lower than main()'s.
another one: heap & stack usually are just residing in two memory segments,
they are not related at all. only in old days, such as the programming C
language book, illustrate as they are growing toward each other.
avatar
o*x
18
你不是买的今天结束的澳大利亚的那个?我是说那个价格不错。

【在 h*******g 的大作中提到】
: 我没贴价格啊?
avatar
d*n
19
thanks for you advice.
I just add a function in main()
print a local variable from fun()
Something like this.
void fun(){int a; cout<main(){
fun();
}
###win32
0035119A
STACK &before=002BF998
HEAP *p=005D83E0
&objA.a002BF988
&objA.b002BF98C
objA=002BF988
STACK &after=002BF970
&a=002BF890 //local variable from fun()
###x64
000000013FB41000
STACK &before=00000000001BF798
HEAP *p=00000000005B67A0
&objA.a00000000001BF7A8
&objA.b00000000001BF7AC
objA=00000000001BF7A8
STACK &after=00000000001BF790
&a=00000000001BF7A0
~~~~~~
so my conclusion is both win32 grows stack downward.
but x64 goes the other way.
suggestions?

's
segments,

【在 g**w 的大作中提到】
: I think your code couldn't tell whether stack growing downward or not. in
: main() function frame, it cut enough from stack for local variable, but it's
: up to compiler to assign them to variables, which order doesn't matter.
: you can try this: call another function from main, in that function print
: out the address of variables, they should be lower than main()'s.
: another one: heap & stack usually are just residing in two memory segments,
: they are not related at all. only in old days, such as the programming C
: language book, illustrate as they are growing toward each other.

avatar
h*g
20
是的,他在PF上挂$500,我没入。
这次ebay上$250搞定还是蛮爽的,就是运费小贵。
卖家和我说他送检什么用掉$180,我拍之前只有200刀的价,他说他基本不想卖了,留
给他侄子算了,他心理价位是500刀。
这个4点结束的,我不可能屏到那么晚,我挂了250美刀就睡了,我自己也没想到能拍下
来。

【在 o*****x 的大作中提到】
: 你不是买的今天结束的澳大利亚的那个?我是说那个价格不错。
avatar
g*w
21
x64 有点奇怪。建议turn off 优化。
其实用windbg很容易看,不用费劲的打印地址

【在 d****n 的大作中提到】
: thanks for you advice.
: I just add a function in main()
: print a local variable from fun()
: Something like this.
: void fun(){int a; cout<: main(){
: fun();
: }
: ###win32
: 0035119A

avatar
c*y
22
那你发包子吧

【在 h*******g 的大作中提到】
: 是的,他在PF上挂$500,我没入。
: 这次ebay上$250搞定还是蛮爽的,就是运费小贵。
: 卖家和我说他送检什么用掉$180,我拍之前只有200刀的价,他说他基本不想卖了,留
: 给他侄子算了,他心理价位是500刀。
: 这个4点结束的,我不可能屏到那么晚,我挂了250美刀就睡了,我自己也没想到能拍下
: 来。

avatar
d*n
23
回去学习,谢谢了

【在 g**w 的大作中提到】
: x64 有点奇怪。建议turn off 优化。
: 其实用windbg很容易看,不用费劲的打印地址

avatar
h*g
24
怎么发?我一直没研究出来,我上次就想发包子了

【在 c********y 的大作中提到】
: 那你发包子吧
avatar
c*y
25
家页->金融中心->转账给个人

【在 h*******g 的大作中提到】
: 怎么发?我一直没研究出来,我上次就想发包子了
avatar
h*g
26
发吧。尤其是我,曾错过若干个LX。。。

【在 h*******g 的大作中提到】
: 是的,他在PF上挂$500,我没入。
: 这次ebay上$250搞定还是蛮爽的,就是运费小贵。
: 卖家和我说他送检什么用掉$180,我拍之前只有200刀的价,他说他基本不想卖了,留
: 给他侄子算了,他心理价位是500刀。
: 这个4点结束的,我不可能屏到那么晚,我挂了250美刀就睡了,我自己也没想到能拍下
: 来。

avatar
S*t
27
re baozi

【在 c********y 的大作中提到】
: 那你发包子吧
avatar
o*x
28
re
包子
avatar
h*g
29
包子发好了,在此之上都有包子
avatar
x*g
30
包子
avatar
h*g
31
朋友,我现在身上一个包子都没了,昨天学会发包子以后狂发。。。

【在 x*****g 的大作中提到】
: 包子
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。