0
votes

On 64-bit win10, when I use swi-prolog, the following fatal error occurred,

SWI-Prolog:[FATAL ERROR: at xx:xx:xx Too many stacked strings]

How can I solve it?

The fact set is about 150000, from the SWI-Prolog-8.2.1.pdf, I found the stack could be set by,

swipl --stack-limit = 32G

But when I execute this command, I don't know it is right or not, can anyone help me?

2

2 Answers

1
votes

"AATAL ERROR" sounds too similar to "FATAL ERROR"

There may a simple explanation:

  1. Are you using the 64-bit version of swi-prolog ?
  2. Reboot Windows and try again, do you still get the same message ?
  3. Set stack sizes at runtime, from within SWI-Prolog, before running your test code
:- set_prolog_stack(global, limit(100000000000)).
:- set_prolog_stack(trail,  limit(20000000000)).
:- set_prolog_stack(local,  limit(2000000000)).
  1. On the command line, use this equivalent command: swipl -G100g -T20g -L2g

Good luck !

0
votes

Please provide some published pl code that leads to the error, so that it can be reproduced by others that want to help you. You can upload it to gist or GitHub even if it is 1000 of facts or so. Maybe you need to anonymize it, because of privacy issues. The MAX_LG_STACKED_STRINGS is only a buffer. From the SWI-Prolog source it is seen that SWI-Prolog does have an internal flag ALERT_BUFFER.

So my rough understanding is that there are multiple MAX_LG_STACKED_STRINGS on the stack. Which would imply that increasing this constant doesn’t solve the problem. This would only increase a kind of block size. And the fatal error could be due to some other problem and/or there is an advice to rewrite your code. In as far it could be also reproducible without the Python interface and on all platforms. Maybe also inside SWISH.

Dunno, dont know what you are doing with strings, since there is no published test case. You could maybe also switch on MSG_STRING_BUFFER debugger message, these messages show me that SWI-Prolog uses multiple buffers:

  DEBUG(MSG_STRING_BUFFER,
      Sdprintf("Discarding string buffers %d..%d\n",
           stack->top, stack->allocated));

   DEBUG(MSG_STRING_BUFFER,
      Sdprintf("Added string buffer entry %p with level %zd\n",
           sb, (size_t)sb->frame));

Edit 31.07.2021:
A test case like here:

FATAL ERROR: Too many stacked strings #102
https://github.com/yuce/pyswip/issues/102