标签: stack-overflow

什么是stackoverflow和bufferoverflow错误?

可能重复:
什么是堆栈溢出错误?

好吧,我听过它在编写程序时遇到的最常见的错误......我是编程新手,只有2年的编码,我从未遇到过这个错误!所以,冒着听起来非常愚蠢的风险,我想问一下......什么是stackoverflow以及什么是bufferoverflow?

stackoverflow是否与缓冲区溢出有关?

一个维基链接实际上不会帮助我因为我已经完成了它并且我不理解它.所以如果你能把它愚蠢......你会怎么说呢?

stack-overflow terminology

-1
推荐指数
1
解决办法
295
查看次数

使用vc ++ 2010在c ++中进行堆栈溢出

我在使用vc ++ 2010编译的程序中遇到了堆栈溢出.我打开一个调试器并将其附加到进程.然后我强制程序在堆栈溢出错误后继续,每次都会出现访问冲突错误.

我的问题是:堆栈溢出导致访问冲突错误?

c++ stack-overflow

-1
推荐指数
1
解决办法
116
查看次数

StackOverflow 与 C# 中的随机名称生成器

using System;


namespace npcnames

{
    class Program
{



    static string RandomVowel()
    {
        Random rand = new Random(); 
        string[] Vowels = new string[5] { "a", "e", "i", "o", "u" };
        int index = rand.Next(Vowels.Length); 
        string Vowel = Vowels[index]; 

        return Vowel;
    }

    static string RandomConsonant()
    {
        Random rand = new Random(); 
        string[] Consonants = new string[21] { "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z" };
        int index = …
Run Code Online (Sandbox Code Playgroud)

c# stack-overflow random generator

-1
推荐指数
1
解决办法
1426
查看次数

如何修复StackOverflowException?

我正在使用StackOverflowException我的C#程序.

Cmodel.cs

public class CModel
{
    public Vector3 Position { get; set; }

    public Vector3 Rotation { get; set; }

    public Vector3 Scale { get; set; }

    public Model Model { get; private set; }

    public BoundingSphere BoundingSphere
    {
        get
        {
            // no need for rotation, as this is a sphere
            Matrix worldTransform = Matrix.CreateScale(Scale) *
            Matrix.CreateTranslation(Position); // THIS IS WHERE THE EXCEPTION OCCURS

            BoundingSphere transformed = BoundingSphere;
            transformed = transformed.Transform(worldTransform);

            return transformed;
        }
    }
    private Matrix[] modelTransforms; …
Run Code Online (Sandbox Code Playgroud)

c# stack-overflow unhandled

-2
推荐指数
1
解决办法
1641
查看次数

设置静态属性C#时出现堆栈溢出异常

可能重复:
C#新手,为什么Property Set会抛出StackOverflow异常?

当我尝试设置静态属性时,我收到了堆栈溢出异常.

public static class StaticTest
{
   static string stringToSet
   {
      get
      {                
          return stringToSet;
      }
      set
      {
          stringToSet = value;
      }
   }
}
Run Code Online (Sandbox Code Playgroud)

然后,在其他课程中:

public void setStaticProperty()
{
    StaticTest.stringToSet = "Hello World";    // StackOverflow exception here
}
Run Code Online (Sandbox Code Playgroud)

我做错了什么?

c# stack-overflow static properties set

-2
推荐指数
1
解决办法
754
查看次数

为什么在实例中创建非静态实例时会发生堆栈溢出错误?

为什么在同一个类的实例中创建非静态实例时会发生堆栈溢出错误?

public class ObjectTest {
    ObjectTest instanceObj = new ObjectTest("Outside");

    public ObjectTest(String s) {
        System.out.println(s);
    }

    public static void main(String[] args) {
        ObjectTest localObj = new ObjectTest("Inside");
    }
}
Run Code Online (Sandbox Code Playgroud)

但是通过以下修改可以解决问题:

static ObjectTest instanceObj = new ObjectTest("Outside");
Run Code Online (Sandbox Code Playgroud)

可以理解的是,在将新对象分配给instanceObj引用时,在第一种情况下发生循环依赖

谁能澄清整个事情?为什么静态引用循环依赖不会发生?

java stack-overflow

-2
推荐指数
1
解决办法
93
查看次数

为什么我的属性会出现StackOverflowException?

请向我解释为什么这段代码产生了一个StackOverflowException.

正如我使用评论所示,其中一行中存在错误.但是,我不明白为什么这会给我一个StackOverflowException.

class TimePeriod
{
    private double seconds;

    public double hour
    {
        get { return hour / 3600; }  // should be :  get { return seconds / 3600; }
        set { seconds = value * 3600; }
    }
}

class Program
{        
    static void Main()
    {
        TimePeriod t = new TimePeriod();
        t.hour = 5;
        System.Console.WriteLine("Time in hours: " + t.hour);
    }
} 
Run Code Online (Sandbox Code Playgroud)

c# stack-overflow

-2
推荐指数
2
解决办法
185
查看次数

如何在C中动态分配内存到2D数组,避免堆栈溢出问题?

pascal = (int **) malloc(no_of_rows * sizeof(int));

for (i = 0; i < no_of_rows; i++)
{
    *(pascal + i) = (int*) malloc(col * sizeof(int));
}
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我这段代码有什么问题,因为我是这门语言的初学者.我继续遇到Stack Overflow的问题?可能的原因是什么?如何避免?

c c++ stack-overflow pointers dynamic

-2
推荐指数
1
解决办法
73
查看次数

堆栈溢出异常,没有递归

我遇到堆栈溢出异常的问题,但我不知道是什么导致异常被抛出.我正在使用一个类库,其中包含我需要的所有方法和对象,并从控制台应用程序运行它.

任何帮助将不胜感激,因为这是一个任务的一部分,将在几个小时内到期.

这是我的代码:

TrafficIncidentNotificationRadiusCalculator类

namespace TrafficIncident
{
public class TrafficIncidentNotificationRadiusCalculator
{
    public double meters;
    public double CONFIGURED_NOTIFICATION_RADIUS
    {
        get { return CONFIGURED_NOTIFICATION_RADIUS; }
        set { CONFIGURED_NOTIFICATION_RADIUS = meters; }
    }

    public List<string> GetNotificationRecipientsList(List<User> users, List<UserLocationUpdate> userLocation, TrafficIncidentReport report)
    {
        int i = 0;
        List<string> userNotificationIds = new List<string>();
        while (i < userLocation.Count)
        {
            UserLocationUpdate userLoc = userLocation.ElementAt(i);
            userNotificationIds.Add(userLoc.userNotificationId);
            Console.WriteLine(userNotificationIds.ElementAt(i));
            i++;
        } 
        return userNotificationIds;
    }
}
}
Run Code Online (Sandbox Code Playgroud)

TrafficIncidentReport类

namespace TrafficIncident
{
public class TrafficIncidentReport
{
    public double[] incidentLocation;

    public double latitude …
Run Code Online (Sandbox Code Playgroud)

c# stack-overflow class-library console-application

-2
推荐指数
1
解决办法
121
查看次数

WinAPI在记事本中挂钩CreateFileW

我制作了一个DLL,它应该CreateFileW从记事本挂钩,但它崩溃了.经过调试后我发现它导致了HookedCreateFile函数第一行的堆栈溢出:

截图

(它说它导致地址异常错误......)

异常点处的callstack:

调用堆栈?

我的代码:

typedef HANDLE(WINAPI * CreateFileFn)(
    LPCWSTR lpFileName,
    DWORD dwDesiredAccess,
    DWORD dwShareMode,
    LPSECURITY_ATTRIBUTES lpSecurityAttributes,
    DWORD dwCreationDisposition,
    DWORD dwFlagsAndAttributes,
    HANDLE hTemplateFile);

CreateFileFn oCreateFile = (CreateFileFn)GetProcAddress(GetModuleHandleA("kernel32.dll"), "CreateFileW");

HANDLE WINAPI HookedCreateFile(
    LPCWSTR lpFileName,
    DWORD dwDesiredAccess,
    DWORD dwShareMode,
    LPSECURITY_ATTRIBUTES lpSecurityAttributes,
    DWORD dwCreationDisposition,
    DWORD dwFlagsAndAttributes,
    HANDLE hTemplateFile)
{
    //std::cout << "Hello!" << std::endl;

    return oCreateFile(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
}
Run Code Online (Sandbox Code Playgroud)

我使用DetourFunction的是Microsoft Detours:

DetourFunction((PBYTE)oCreateFile, (PBYTE)HookedCreateFile);
Run Code Online (Sandbox Code Playgroud)

c++ stack-overflow hook winapi detours

-2
推荐指数
1
解决办法
133
查看次数