24小时热门版块排行榜    

查看: 1693  |  回复: 12
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

relonfbq

金虫 (正式写手)


[交流] 【求助】fortran程序问题

我用的VS2008下的fortran,我的调试程序时,每次进入某函数时,其总会跳到一个名为chkstk.asm文件中,几步之后又调回来,我不知道这那里有问题,这个文件内容是: page    ,132
        title   chkstk - C stack checking routine
;***
;chkstk.asm - C stack checking routine
;
;       Copyright (c) Microsoft Corporation. All rights reserved.
;
;Purpose:
;       Provides support for automatic stack checking in C procedures
;       when stack checking is enabled.
;
;*******************************************************************************

.xlist
        include cruntime.inc
.list

; size of a page of memory

_PAGESIZE_      equ     1000h


        CODESEG

page
;***
;_chkstk - check stack upon procedure entry
;
;Purpose:
;       Provide stack checking on procedure entry. Method is to simply probe
;       each page of memory required for the stack in descending order. This
;       causes the necessary pages of memory to be allocated via the guard
;       page scheme, if possible. In the event of failure, the OS raises the
;       _XCPT_UNABLE_TO_GROW_STACK exception.
;
;       NOTE:  Currently, the (EAX < _PAGESIZE_) code path falls through
;       to the "lastpage" label of the (EAX >= _PAGESIZE_) code path.  This
;       is small; a minor speed optimization would be to special case
;       this up top.  This would avoid the painful save/restore of
;       ecx and would shorten the code path by 4-6 instructions.
;
;Entry:
;       EAX = size of local frame
;
;Exit:
;       ESP = new stackframe, if successful
;
;Uses:
;       EAX
;
;Exceptions:
;       _XCPT_GUARD_PAGE_VIOLATION - May be raised on a page probe. NEVER TRAP
;                                    THIS!!!! It is used by the OS to grow the
;                                    stack on demand.
;       _XCPT_UNABLE_TO_GROW_STACK - The stack cannot be grown. More precisely,
;                                    the attempt by the OS memory manager to
;                                    allocate another guard page in response
;                                    to a _XCPT_GUARD_PAGE_VIOLATION has
;                                    failed.
;
;*******************************************************************************

public  _alloca_probe

_chkstk proc

_alloca_probe    =  _chkstk

        push    ecx

; Calculate new TOS.

        lea     ecx, [esp] + 8 - 4      ; TOS before entering function + size for ret value
        sub     ecx, eax                ; new TOS

; Handle allocation size that results in wraparound.
; Wraparound will result in StackOverflow exception.

        sbb     eax, eax                ; 0 if CF==0, ~0 if CF==1
        not     eax                     ; ~0 if TOS did not wrapped around, 0 otherwise
        and     ecx, eax                ; set to 0 if wraparound

        mov     eax, esp                ; current TOS
        and     eax, not ( _PAGESIZE_ - 1) ; Round down to current page boundary

cs10:
        cmp     ecx, eax                ; Is new TOS
        jb      short cs20              ; in probed page?
        mov     eax, ecx                ; yes.
        pop     ecx
        xchg    esp, eax                ; update esp
        mov     eax, dword ptr [eax]    ; get return address
        mov     dword ptr [esp], eax    ; and put it at new TOS
        ret

; Find next lower page and probe
cs20:
        sub     eax, _PAGESIZE_         ; decrease by PAGESIZE
        test    dword ptr [eax],eax     ; probe page.
        jmp     short cs10

_chkstk endp

        end
大家帮我看看那里出来问题???????????
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

» 抢金币啦!回帖就可以得到:

查看全部散金贴

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

relonfbq

金虫 (正式写手)


引用回帖:
Originally posted by dingxb at 2011-04-14 10:39:56:
我没有遇到过类似问题。

似乎有许多的C/C++程序员遇到过类似问题,大多都是堆栈溢出(或者堆栈使用)造成的。

有人建议,可能与动态数组有关。可以将动态数组先换为静态数组,再行调整。

希望一下帖子对 ...

谢谢!
我刚刚调试发现,传递的数组,在进入该子程序之前是正常的,但一进入该子程序,数组就元素的个数就变小了,怎么会突然变少呢?这其中原因在哪儿呢?
10楼2011-04-14 10:50:32
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 13 个回答

dingxb

金虫 (正式写手)



微尘、梦想(金币+1): 谢谢回复…… 2011-04-14 21:13:49
貌似是检查堆栈大小的C汇编程序。

建议,设置堆栈大小为较大的值,同时,这个问题如果是运行时错误,建议你缩小程序的规模。

比如,你原来用到100000维数组,你可以先做小规模测试,用100维。

Good luck.
2楼2011-04-14 07:49:54
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

relonfbq

金虫 (正式写手)


引用回帖:
Originally posted by dingxb at 2011-04-14 07:49:54:
貌似是检查堆栈大小的C汇编程序。

建议,设置堆栈大小为较大的值,同时,这个问题如果是运行时错误,建议你缩小程序的规模。

比如,你原来用到100000维数组,你可以先做小规模测试,用100维。

Good luck.

怎么设置堆栈????
我进入的函数调用一个数组,数组维数为1,数组元素的个数只有128个,也不算多啊????
4楼2011-04-14 09:28:23
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dingxb

金虫 (正式写手)


呃,sorry,win下没怎么写过程序,具体的东西不是很清楚。

这一调用是否影响计算结果??
5楼2011-04-14 09:30:39
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
普通表情 高级回复(可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[硕博家园] 夏至,要不要硕博联谊 +5 我是王小帅 2024-06-21 7/350 2024-06-26 20:45 by 喔喔。
[基金申请] 基你太美 +13 lyfbangong 2024-06-24 15/750 2024-06-26 17:12 by lyfbangong
[考研] 刚当完兵回来想考研 +7 五官在线 2024-06-23 18/900 2024-06-26 17:05 by 1158057902
[基金申请] 国产期刊影响因子大于12的有20多个个了 +19 babu2015 2024-06-20 24/1200 2024-06-26 16:57 by deliciou
[论文投稿] 我在写关于多维空间的论文,希望能与大家交流,准备在science上发表 +8 lgf519 2024-06-24 10/500 2024-06-26 16:25 by 梦渺岚烟
[基金申请] 博后面上今天下午会公布吗?有无消息? +26 hajkdfdf 2024-06-24 43/2150 2024-06-26 16:04 by kyukitu
[基金申请] 博后面上今天下午会公布吗?大家有无消息? +9 地理学1995 2024-06-24 13/650 2024-06-26 16:02 by kyukitu
[基金申请] 博后面上和特助今天出吗? +41 逗您玩 2024-06-21 78/3900 2024-06-26 16:00 by HAPPY_0225
[有机交流] 酚羟基甲基化 10+4 A好运来啦啦啦 2024-06-25 6/300 2024-06-26 10:08 by 88817753
[基金申请] 今天能不能出来名单 +8 地理学1995 2024-06-25 10/500 2024-06-26 09:46 by msjy
[有机交流] 过柱子,产品,杂质在是 pe:ea=100:1 也一起出来? +5 w256 2024-06-25 5/250 2024-06-26 09:31 by 小木木cc
[考博] 没读上博,好焦虑! +6 wangzhe_bs 2024-06-24 8/400 2024-06-25 21:15 by wangzhe_bs
[有机交流] 对苯乙烯磺酰氯的合成机理 25+3 该死的科研 2024-06-24 5/250 2024-06-25 17:30 by 王学士
[第一性原理] Vasp 版权问题 10+4 竹叶青9 2024-06-22 5/250 2024-06-25 14:58 by 无所谓109
[有机交流] 求助析晶问题 20+4 dengdawang 2024-06-24 5/250 2024-06-24 21:22 by cc116
[公派出国] 博士csc联培会看重第一学历学校层次吗 +4 也就这样 2024-06-23 4/200 2024-06-24 08:18 by 晓目崇
[基金申请] 国自然青年基金,1A4B能上会吗?青年和面上的上会标准是一样的吗? +19 今晚推荐22 2024-06-20 32/1600 2024-06-23 23:17 by andywei1028
[有机交流] 求助 45+7 脂质纳米粒 2024-06-20 9/450 2024-06-23 07:52 by buhui7829
[基金申请] 教育部基金 +5 m1393 2024-06-21 5/250 2024-06-21 21:13 by odes
[基金申请] 听大佬说今年信息口本子数量大幅增加? +8 wutzxt 2024-06-21 9/450 2024-06-21 19:58 by wutzxt
信息提示
请填处理意见