SBCL错误:"绑定堆栈耗尽"在Linux机器

时间:2017-10-09 02:03:44

标签: linux lisp common-lisp sbcl maxima

我知道有很多地方我可以问这个问题,但我想我会在这里试试。我似乎已经从Maxima的好人那里获得了尽可能多的帮助。

我使用SBCL运行Maxima并始终出错;

INFO: Binding stack guard page unprotected
Binding stack guard page temporarily disabled: proceed with caution

Maxima encountered a Lisp error:

 Binding stack exhausted.

PROCEED WITH CAUTION.

Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.
INFO: Binding stack guard page reprotected

我通过为动态空间大小控制堆栈大小添加更大的值来修改对Maxima(其可执行文件)的调用,我看了一下 ./.../ sbcl -help ,用于添加到maxima可执行文件中 $ MAXIMA_LISP_OPTIONS 的任何参数构思。

另外,我通常在运行它之前就做这些(虽然我认为它们是不必要的,因为操作系统很聪明,也许最后一个需要摆弄);

sudo fstrim -v /
echo 3 | sudo tee /proc/sys/vm/drop_caches
echo 262144 | sudo tee /proc/sys/vm/max_map_count

在完成Maxima工作的几次计算之后,我投入了几个

:lisp (sb-ext:gc :full t)

希望避免这种错误。我不太了解口齿不清,当然也不了解垃圾收集的所有内容。

我的计算有点密集和递归,尽管我在Maxima工作中使用了memoization。我的计算机由 inxi -b 描述为

System:    Host: XXX-MacBookPro Kernel: 4.10.0-33-generic x86_64 (64 bit) Desktop: Cinnamon 3.4.6
           Distro: Linux Mint 18.2 Sonya
Machine:   System: Apple (portable) product: MacBookPro11 3 v: 1.0
           Mobo: Apple model: Mac-2BD1B313 v: MacBookPro11 3
           Bios: Apple v: MBP112.88Z.0138.B25.1702171721 date: 02/17/2017
CPU:       Quad core Intel Core i7-4980HQ (-HT-MCP-) speed/max: 1402/4000 MHz
Graphics:  Card: NVIDIA GK107M [GeForce GT 750M Mac Edition]
           Display Server: X.Org 1.18.4 drivers: nvidia (unloaded: fbdev,vesa,nouveau)
           Resolution: 2880x1800@59.99hz
           GLX Renderer: GeForce GT 750M/PCIe/SSE2 GLX Version: 4.5.0 NVIDIA 375.66
Network:   Card-1: Broadcom BCM4360 802.11ac Wireless Network Adapter driver: wl
           Card-2: Broadcom NetXtreme BCM57762 Gigabit Ethernet PCIe driver: tg3
Drives:    HDD Total Size: 1000.6GB (17.5% used)
Info:      Processes: 291 Uptime: 43 min Memory: 3366.6/15953.7MB Client: Shell (bash) inxi: 2.2.35 

我的Maxima和SBCL都是由GIT构建的,并且是相当新的〜大约2周,并且从头开始并且已经通过了他们所有的测试。另外我的交换看起来像;

XXX@XXX-MacBookPro ~/ResearchWC $ cat /proc/swaps 
Filename                Type        Size    Used    Priority
/70GiB.swap                             file        73400316    0   -2
/dev/sda7                               partition   25564776    0   -1

我经常基本上没有内存,而且大约在20-30G之间进行交换。

通常它似乎最终会挂起(比如100小时之后,因为我注意到 htop 停止显示某些活动并且粉丝不会上下移动)我认为耗尽错误是有时埋在嵌入式递归调用中。我上面得到了这个错误消息,因为我避免在我想要的递归级别调用函数,而是将它们构建起来"手工"在码头。 E.G.,而不是仅仅调用像fib(10)这样的东西,而是先后调用fib(1),fib(2),fib(3),其中每个先前的值都被记忆了。

我有时间,但似乎不知道如何最大化我的交换 - 观看 htop 我从未见过它使用超过25%。

1。)有谁知道我还可以用SBCL做些什么来避免这些错误?

2。)在这些情况下,另一个lisp是否会更好? ecl,cml等?

提前感谢任何建议,如果需要,我可以提供更多详细信息。

更新

在增加动态空间大小,堆栈大小和绑定堆栈大小之后,这次崩溃时我遇到了堆限制而不是绑定堆栈。附加是回溯的输出(不确定两个寄存器pc和fp是什么...... - 程序计数器和帧指针?)。我用痕迹(残留物,泰勒)也跑了这个,但从来没有看到任何可疑的东西......

ldb> backtrace
Backtrace:
   0: SB-BIGNUM::MULTIPLY-BIGNUM-AND-FIXNUM, pc = 0x21cb1336, fp = 0x7ffff3943f18
   1: SB-KERNEL::TWO-ARG-*, pc = 0x21cb00a7, fp = 0x7ffff3943f98
   2: MAXIMA::CTIMES, pc = 0x21e076b4, fp = 0x7ffff3943fc0
   3: MAXIMA::PCTIMES, pc = 0x21de5f4c, fp = 0x7ffff3943ff0
   4: MAXIMA::PCTIMES1, pc = 0x21e78f1e, fp = 0x7ffff3944048
   5: MAXIMA::PCTIMES, pc = 0x21de6033, fp = 0x7ffff3944078
   6: MAXIMA::PCETIMES1, pc = 0x21fe0560, fp = 0x7ffff39440d8
   7: MAXIMA::PTIMES1, pc = 0x21f457e5, fp = 0x7ffff3944148
   8: MAXIMA::PTIMES, pc = 0x21db6561, fp = 0x7ffff3944180
   9: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff39441b8
  10: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff39441f0
  11: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944228
  12: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944260
  13: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944298
  14: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff39442d0
  15: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944308
  16: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944340
  17: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944378
  18: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff39443b0
  19: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff39443e8
  20: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944420
  21: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944458
  22: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944490
  23: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff39444c8
  24: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944500
  25: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944538
  26: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944570
  27: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff39445a8
  28: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff39445e0
  29: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944618
  30: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944650
  31: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944688
  32: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff39446c0
  33: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff39446f8
  34: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944730
  35: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944768
  36: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff39447a0
  37: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff39447d8
  38: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944810
  39: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944848
  40: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944880
  41: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff39448b8
  42: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff39448f0
  43: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944928
  44: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944960
  45: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944998
  46: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff39449d0
  47: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944a08
  48: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944a40
  49: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944a78
  50: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944ab0
  51: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944ae8
  52: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944b20
  53: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944b58
  54: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944b90
  55: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944bc8
  56: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944c00
  57: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944c38
  58: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944c70
  59: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944ca8
  60: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944ce0
  61: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944d18
  62: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944d50
  63: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944d88
  64: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944dc0
  65: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944df8
  66: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944e30
  67: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944e68
  68: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944ea0
  69: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944ed8
  70: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944f10
  71: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944f48
  72: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944f80
  73: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3944fb8
  74: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3944ff0
  75: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3945028
  76: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3945060
  77: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3945098
  78: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff39450d0
  79: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3945108
  80: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3945140
  81: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3945178
  82: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff39451b0
  83: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff39451e8
  84: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3945220
  85: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3945258
  86: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3945290
  87: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff39452c8
  88: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3945300
  89: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3945338
  90: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3945370
  91: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff39453a8
  92: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff39453e0
  93: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3945418
  94: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3945450
  95: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff3945488
  96: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff39454c0
  97: MAXIMA::PSIMP, pc = 0x21dd0617, fp = 0x7ffff39454f8
  98: MAXIMA::PALGSIMP, pc = 0x22166db7, fp = 0x7ffff3945530

1 个答案:

答案 0 :(得分:4)

绑定堆栈溢出的最常见原因是递归函数,它无限地调用自身(即递归中的错误)。第二个最常见的原因是一个正确编程的递归函数,但调用自身太多次以使Lisp实现处理它。

我忘记了SBCL的堆栈限制 - 它可能是8192,但这只是猜测。您可以通过实验确定它(如果不是通过阅读SBCL文档)。

在任何一种情况下,您都可以尝试通过

找出导致问题的功能
trace (mymaximafun1, mymaximafun2, ...);

用于Maxima函数和/或

:lisp (trace mylispfun1 mylispfun2 ...)

用于Lisp函数。

关于第二个问题,您可以尝试通过将递归函数重新设置为迭代来避免深度递归。

你提到你有长时间运行的计算。减少崩溃影响的策略是调用save函数来不时地保存程序状态,例如:

save ("mycheckpointfile.lisp", all);

请注意,save需要很多选项,因此可以通过? save查看文档。

您可以通过file_name : printf(false, "mycheckpointfile~d.lisp", 1000 + random(9000))之类的配方自动生成文件名,这些配方会生成一个随机的4位数字并将其粘贴到文件名中。当然有很多这样的食谱。