Too many stacked Strings

This reply is meant for the OP.

Two options using SWI-Prolog:

  1. Protocol/1 (Used to capture screen to file)
  2. Use tell/1 and told/0. e.g. tell('my_file.txt'), goal(Arguments), told.

Hi,
1- @j4n_bur53 It writes the following output when I add the writelns,

reached to here 3
reached to here 2
reached to here 3
reached to here 2
reached to here 3
reached to here 2
reached to here 3
reached to here 2
reached to here 3
reached to here 2
reached to here 3
SWI-Prolog: [FATAL ERROR: at Sat Jul 31 12:50:07 2021
	Too many stacked strings]

Process finished with exit code 3

2-It stops at the call path_generic(‘B’,‘21’, P). But not at its first call. I mean I call this several times before. But at its xth time this occurs not at first.

3-When I run

?- path_generic('B', '21', P).`I get
ERROR: Unknown procedure: arc/2
ERROR:   However, there are definitions for:
ERROR:         arg/3
ERROR: 
ERROR: In:
ERROR:   [13] arc(_8442,_8444)
ERROR:   [12] travel(_8468,_8470,[_8478],[_8484,_8490]) at d:/path/python/graph_traversal_old.pl:10
ERROR:   [11] path(_8516,_8518,_8520) at d:/path/python/graph_traversal_old.pl:9
ERROR:   [10] path_generic('B','21',_8548) at d:/path/python/graph_traversal_old.pl:6
ERROR:    [9] <user>
   Exception: (13) arc(_1528, _1534) ?

4-@peter.ludemann I am not sure if I can do this with substring. I will think about it, thanks for the idea.

5-Prolog Version

?-  prolog_flag(version, Z).
Z = 'SWI-Prolog 8.2.4 (x64-win64): Jan 27 2021, 07:50:16'.

6-Is there a comamnd which I can call to clear the stack, prior to each path_generic call?

Many thanks for your interest and efforts,
Ferda

In searching (search) the GitHub SWI-Prolog repository found

The last manual response is

@Marco299 the fix was introduced in PySwip, not in SWI-Prolog. If you’re using PySwip, then install it from master and see if you’re still experiencing the issue.

HTH


FYI

Since I added a link in this post to the issue, Discourse automatically added a reply in the issue with a link to this post.


EDIT

I do not use pyswip but it has a closed issue

but more importantly has a Minimal Reproducible Example. (Which I did not try.)


EDIT

This fix looks to be after your current SWI-Prolog version SWI-Prolog 8.2.4 (x64-win64): Jan 27 2021, 07:50:1 so you need to also update SWI-Prolog if you have not done so.

1 Like

Hi,
I added the ARC facts manually to the pl file but I made an error. This time I fixed it.
When I call I get no error (which is normal cause it does not happen the in first call).

1 ?- path_generic('B', '21', P).
P = ['B_1', '21_1'] .

I already saw that link which says calling function from pl not from python. It does not suit my code structure, unfortunately :frowning:

Is there a way to fix this bug or whatever with its current structure please?

We don’t know where the bug is, as discussed above

Hi,
I can not decrease the number of path_generic calls, actually, it will increase once the metadata becomes complete. I couldn’t understand the other stuff related to PL_STRINGS_MARK(), RELEASE(). Is there a way to call that lines from python?

Many thanks,
Ferda

The PL_STRINGS_MARK()/RELEASE() macros are part of the SWI-Prolog foreign interface. Like the somewhat related PL_open_foreign_frame() and PL_close_foreign_frame() pair, they are required to avoid building up garbage on the Prolog side. It is up to the Python interface to deal with this.

1 Like

Hi,
I downloaded the SWI-Prolog code and bypassed that control which checks the MAX_LG_STACKED_STRINGS and rebuild it. Now it works for me. This may not be the best idea but I needed a quick solution for now. I may provide the compiled package if anyone wants.

Thanks for all the contributions,
Ferda

1 Like

Hi,
I will check that header file tomorrow. You have a reason, I understand. I just neeced something to fix.
Kind Regards,
Ferda