标签: stack-overflow

生成堆栈溢出

如何在GNU/linux中创建堆栈溢出的条件?

c linux stack-overflow

0
推荐指数
3
解决办法
3922
查看次数

使用Javascript类函数进行15次递归后的堆栈溢出

我有以下代码示例来说明我的观点.当我在Vista上的IE8中加载它时,我收到错误"Stack Overfow at line:16"

如果我使用顶级函数(在testClass对象之外)递归,我可以在没有堆栈溢出的情况下递归数百万次.

为什么会这样?最后我只是实现了一个函数Que而不是使用递归,但对我来说没有意义,我想了解原因.

- 代码 -

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
<html>
    <head>
        <title>Recusion Test</title>
        <body>
        </body>

        <script type="text/javascript">

            function testClass() {
                this.x = 15;
                this.recurse = function() {
                    this.x--;
                    this.recurse();
                }
            }

            var wtf = new testClass();
                wtf.recurse();

            alert('done');
        </script>
    </head>
</html>
Run Code Online (Sandbox Code Playgroud)

javascript stack-overflow recursion class stackpanel

0
推荐指数
1
解决办法
145
查看次数

创建类的新实例时出现C#StackOverFlowException

嗯,我遇到了一个奇怪的问题。当我创建类的新实例时,我得到StackOverflowExcepion :)

这是代码:

public partial class PlayerChooser : Window
{
public PlayerChooser()
    {
        InitializeComponent();
        textBoxPlayer1Name.Visibility = Visibility.Hidden;
        textBoxPlayer2Name.Visibility = Visibility.Hidden;
        textBoxPlayer3Name.Visibility = Visibility.Hidden;
        textBoxPlayer4Name.Visibility = Visibility.Hidden;

    }

    public static String player1Name;
    public static String player2Name;
    public static String player3Name;
    public static String player4Name;
    ...

    PlayerChooser.player1Name = textBoxPlayer1Name.Text;
    PlayerChooser.player2Name = textBoxPlayer2Name.Text;
    TwoPlayers501_new twoPlayers501_new = new TwoPlayers501_new();
    twoPlayers501_new.Show();
    ...
}
Run Code Online (Sandbox Code Playgroud)

以及发生异常的类和构造函数

public partial class TwoPlayers501_new : Window
{
    public TwoPlayers501_new()
    {
        InitializeComponent();

        textBlockPlayer1Name.Text = PlayerChooser.player1Name;
        textBlockPlayer2Name.Text = PlayerChooser.player2Name;
    }
    ...
}
Run Code Online (Sandbox Code Playgroud)

预先感谢,这可能有点琐碎...

c# stack-overflow wpf instance

0
推荐指数
1
解决办法
1123
查看次数

尝试分配通用数组时,C#程序崩溃

请考虑以下代码:

    public class LimitedBuffer<T> {

    /// <summary>
    /// 
    /// </summary>
    public const int DefaultSize = 10;

    /// <summary>
    /// 
    /// </summary>
    private T[] buffer;

    /// <summary>
    /// 
    /// </summary>
    private int poe;

    /// <summary>
    /// 
    /// </summary>
    private int pow;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="size"></param>
    public LimitedBuffer(int size = 10) {
        // Buffer instantiation
        this.buffer = new T[10];
        // Value initialization
        for (int i = 0; i < this.buffer.Length; i++)
            this.buffer[i] = default(T);
        this.pow = 0;
        this.poe …
Run Code Online (Sandbox Code Playgroud)

.net c# stack-overflow arrays allocation

0
推荐指数
1
解决办法
177
查看次数

StackOverflowException没有明显的原因..这真的很烦人

WHYYYYYYY?

以下是我的一半代码,因为我已经删除了大部分代码以及我在尝试解决此问题时丢失的每一根头发.无论我删除或更改什么,我都会收到StackOverflowException.

这是非常奇怪的,因为这个完全相同的代码更早.

请给我任何建议,因为我很无能为力......

我检查了这个,我不认为这是发生的事情:

  • 无限递归循环
  • 程序只是耗尽堆栈空间

­

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Net;

namespace ConsoleApplication10
{
class Program
{
    public int currentDialogueID = 0;

    List<NPC> NPCList = new List<NPC>() {
            new NPC(0, "Man", 1, true),
            new NPC(1, "Woman", 1, true),
            new NPC(2, "Troll", 3, true)
        };

    static void Main(string[] args)
    {
        Program d = new Program();
        d.Init();
        Console.ReadKey(false);
    }

    void Init()
    {
        getNPCByName("Man").NPCDialogue();
    }

    public NPC getNPCByName(string npcName)
    {
        IEnumerable<NPC> myNPCsName …
Run Code Online (Sandbox Code Playgroud)

c# stack-overflow

0
推荐指数
1
解决办法
173
查看次数

为什么普通的类实例化会导致未处理的溢出异常?

除了初始化的普通类之外,我看不到任何其他内容.

这是类,类Bet.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lab_ADayAtTheRaces
{
public class Bet : Form1
{
    public int Bets_Joe;
    public int Bets_Bob;
    public int Bets_Al;
    public int Dog_Joe;
    public int Dog_Bob;
    public int Dog_Al;

    public int Amount;
    public int Dog;
    public Guy Bettor;

    public string GetDescription()
    {
        Amount = (int)numericUpDownBucksToBet.Value;
        Dog = (int)numericUpDownDogToBetOn.Value;
        //Bettor =
        return Bettor + " placed a bet in the amount of " + Amount + " bucks on dog number …
Run Code Online (Sandbox Code Playgroud)

c# stack-overflow exception class

0
推荐指数
1
解决办法
406
查看次数

带有指向字符数组的strcpy函数

在下面的代码中,结果是堆栈溢出.尽管两个字符串都有空字符,但strcpy循环应该终止,因为源字符串具有空字符.为什么发生堆栈溢出?

#include <stdio.h>
#include<strings.h>
int main(void) {
    char *str="Hello world";
    char *str1="Good morning";
    strcpy(str,str1);
    printf("%s",str);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c stack-overflow pointers strcpy

0
推荐指数
1
解决办法
1322
查看次数

为什么我在数组中的索引0上遇到堆栈溢出错误

这是我的战士班.我想在这堂课上有一系列的战士.我们的想法是能够调用这样的方法 - > warrior.select(1),它将获得在索引1处创建的战士.希望这是有意义的.请向我解释为什么会发生这种错误.

Exception in thread "main" java.lang.StackOverflowError
    at pking.Warrior.<init>(Warrior.java:42)
Run Code Online (Sandbox Code Playgroud)

码

package pking;

public class Warrior {

    private String name;
    private int age;
    private String call;
    private int attackPower;
    private String weapon;

    public Warrior(String myName, int myAge, String myCall, int myAttackPower) {
        name = myName;
        age = myAge;
        call = myCall;
        attackPower = myAttackPower;
        weapon = "";
        Warrior[] warriors = new Warrior[4];
        warriors[0] = new Warrior("Spartacus", 40, "I AM SPARTACUS!", 9000);
        warriors[1] = new Warrior("Crixus", 35, "CHAMPION OF CAPUA", …
Run Code Online (Sandbox Code Playgroud)

java stack-overflow

0
推荐指数
1
解决办法
54
查看次数

lisp -how检查所有列表是否都是数字

我构建这个函数来检查列表中的所有"var"是否都是数字.这是我试图做的

(defun check6 (list) 
(if  (null list) 'TRUE)
(if (not (numberp(first list))) nil)
(check6 (rest list)))
Run Code Online (Sandbox Code Playgroud)

但总是我得到堆栈溢出.

告诉我为什么?

lisp stack-overflow

0
推荐指数
1
解决办法
7220
查看次数

OCaml:pervasives.ml中的Stack_overflow异常

我有一个Stack_overflow在我的OCaml程序错误最近.如果我打开回溯,我看到异常是由"原始操作""pervasives.ml"引发的,第270行.我进入了OCaml源代码,看到第270行定义了函数@(即列表追加).我没有从回溯中获得任何其他信息,即使在我的程序中抛出异常也没有.我切换到字节码并尝试ocamldebug,它没有帮助(没有产生回溯).

我认为这是一个非常奇怪的情况.在我的程序中我使用列表的唯一地方是(a)构建包含整数1到1000000的列表,(b)按顺序遍历RBT并将结果放入列表中,以及(c)打印整数列表包含表面上1000000的数字.我已经测试了所有函数,并且它们都没有包含无限循环,我认为1000000甚至不是一个巨大的数字.此外,我已经在Haskell(GHC),Scala和SML(MLton)中尝试了相当于我的程序,并且所有这些版本在相当短的时间内完美地工作.那么,问题是,可能会发生什么?我可以调试吗?

stack-overflow debugging ocaml

0
推荐指数
1
解决办法
141
查看次数