为什么Win32应用程序会在“返回”时立即崩溃声明被称为? [英] Why Win32 application crashes as soon as "return" statement is called?

查看:63
本文介绍了为什么Win32应用程序会在“返回”时立即崩溃声明被称为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-       ;    
应用程序:Win32(由VS2015 Professional上的C / C ++编写)

-           
使用SetUnhandledExceptionFilter()API捕获异常。

我有2个问题。请帮我解答

我尝试通过硬代码在我的应用程序中引发异常

int func_a ()

{

    ...

    memset(arr,0,10000);

    ; ...

   返回1;  //
à 程序在这里崩溃

    return 1;  // à program is crashed here

}

只要语句"返回0",程序就会崩溃。它可能是由堆栈内存损坏引起的。

但是,你能解释一下吗? SetUnhandledExceptionFilter()API无法捕获此异常的原因是什么?

推荐答案

您好,

"返回1"不会"崩溃"你的计划。也许它发生在返回之前的行中。返回前的行是什么?

"return 1" will not "crash" your programme. Maybe it happens in the line before the return. What is the line before the return?

给我们提供更多信息。你显示数组arr,它具有哪种类型和大小?它是"int arr [10000]"吗?

Give us more information. You show array arr, which type and size does it have? Is it "int arr[10000]"?

什么是"崩溃"?你明白吗?向我们显示异常消息。

What "crash" do you get? Show us the exception message.

以下是有关例外的文档:
https://www.codeproject.com/Articles/207464/Exception-Handling-in-Visual-Cplusplus

Here is a documentation about exceptions: https://www.codeproject.com/Articles/207464/Exception-Handling-in-Visual-Cplusplus

此致,Guido < a href ="https://www.codeproject.com/Articles/207464/Exception-Handling-in-Visual-Cplusplus">


这篇关于为什么Win32应用程序会在“返回”时立即崩溃声明被称为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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