Windows系统默认分页大小为1M 1024 *1024,当申请的空间大于1M时就会出现如下问题:
1.在Debug下调试程序,出现如下错误:test dword ptr [eax],eax ; probe page.
Stack overflow
2.通过debug就会进入以下文件chkask.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
3.解决方法:1.减小申请空间的大小
2.大栈空间的大小 方法为:项目->属性->链接器->系统->堆栈保留大小
分享到:
相关推荐
《Prentice.Hall.PTR.UNIX.Shells.by.Example.4th.Edition.Sep.2004.eBook-DDU》是一部关于UNIX shell编程的经典教程,由第四版出版于2004年。这本书深入浅出地介绍了UNIX系统中的各种shell,包括Bash、C Shell、...
Comprehensive Real-World Guidance for Every Embedded Developer and Engineer This book brings together indispensable knowledge for building efficient, high-value, Linux-based embedded products: ...
无线收发数传MODEM 模块PTR2000 的原理与应用.pdf
《Dword Ptr指令详解》 在8086CPU的指令系统中,为了处理不同尺寸的数据,如字节(byte)和字(word),汇编语言提供了一种明确指定数据尺寸的方法。其中,`dword ptr`指令是用于指定操作数为双字(dword,即32位)的...
标题中的"ptr-19.5.3.tar.gz"是一个典型的软件发布包名称,它包含了几个关键信息。首先,"ptr"很可能是该库的缩写或者项目名称,但具体含义需要查阅相关文档才能确定。其次,"19.5.3"是版本号,表明这是该库的第19个...
《Prentice.Hall.PTR.Service.Oriented.Architecture.Concepts.Technology.and.Design》是一本关于服务导向架构(Service-Oriented Architecture,SOA)的权威著作,旨在深入探讨SOA的基本概念、技术实现以及设计...
1. **PTR周期**:包括模具、设备调整、PPAP(Production Part Approval Process)、ETR(Engineering Test Report)审批、PTR审批、物料加工和运输时间、在工厂的实施时间等。这些环节都需要考虑在内,以确保工程...
Prentice.Hall.PTR.SELinux.by.Example.Using.Security.Enhanced.Linux.Jul.2006
prentice.hall.ptr.unix.to.linux.porting.a.comprehensive.reference.apr.2006.chm
Prentice.Hall.PTR.IBM.WebSphere.Deployment.and.Advanced.Configuration.Aug.2004.eBook-DDU.chm
《智能指针shared_ptr及其应用》 在C++编程中,动态内存管理是不可或缺的一部分,尤其是在处理复杂的数据结构和跨对象共享数据时。然而,手动管理内存可能导致内存泄漏或者过早释放的问题。为了解决这些问题,C++...
Prentice.Hall.PTR.IBM.WebSphere.Deployment.and.Advanced.Configuration.Aug.2004.eBook-DDU.chm
glyma.Wm82.gnm4.4PTR.genome_main.fna.gz
在C++编程中,`shared_ptr`和`unique_ptr`是智能指针的两种主要类型,它们用于管理对象的生命周期,以防止内存泄漏。在某些情况下,可能由于库的限制或者特定环境不支持Boost或C++11及更高版本,导致无法使用标准库...
relational mapping Practical test-driven development: constructing automated unit test suites and using mock objects to \"test from the inside out\" Leveraging the full value of Eclipse and other IDEs...
在给定的压缩包文件中,我们有两个C语言源代码文件——`ptr_struct_file.c`和`buff_type_test.c`。这些文件主要涉及到Linux环境下的程序开发,利用C语言进行编程。在这里,我们将深入探讨这两个文件可能涉及的关键...
Linux服务器配置之DNS配置 区域文件(位于/var/named/): ...$TTL 86400 ...2002103000 28800 14400 ...216.168.192.in-addr.arpa....216.168.192.in-addr.arpa....133.216.168.192.in-addr.arpa....252 IN PTR ftp.xuwin.com.
《Muska & Lipman PTR Beginning C# Game Programming》是一本专为初学者设计的C#游戏编程入门书籍。这本书引导读者逐步了解并掌握使用C#语言进行游戏开发的基础知识和技巧。C#作为.NET框架的核心编程语言,因其简洁...