Hi,
I am having this error, using prolog from python. In stackoverflow it says that, I could call the below command
swipl -G100g -T20g -L2g
or I could add the below lines.
None of them solved the problem in my case.
I found out the problem occurs due to a variable MAX_LG_STACKED_STRINGS which is set to 20. The related files are:
src/os/pl-buffer.h and src/os/pl-buffer.h
Hi there! Could you tell us what the problem is, what error youâre getting, and what code (at least what query) youâre getting it in? I see a screenshot of the GitHub site but that doesnât provide any information about what your problem actually is.
No matter what, you absolutely should not need to recompile Prolog itself, donât worry about that!
Hi
You are very right. I get the below error, when I run the pl code from python interface. It occurs on relatively larger data which caused more calls mainly (I guess).
I think if someone could update that constant to like 2000 or if they can make it configurable then the problem will be solved.
Many thanks and thank you for your interestâŚ
Ferda
SWI-Prolog: [FATAL ERROR: at Fri Jul 30 21:01:39 2021
Too many stacked strings]
Hi,
I pointed out the lines where the error comes from. I think, at this point it would be harder to try to recreate the error in your PCs. It works together with (it is called based on) some metadata stored in python files. So, very difficult to recreate the error in your PCs. I would have to share all my software. Instead, I already found the error source in the C source file. It is due to a limitation of a defined low number.
PL code is not very complicated, it basically makes some path searches in a tree based on some conditions.
The error occurs when I call path_generic. I need to use sub_atomâs cause my program needs it. This is all I can say. I am sorry. This is part of an academic study and I do not feel very comfortable discussing the details of my code and I am not allowed to do also.
As I said, I can not provide all the details to reproduce it, for it to happen, I need to share all my software which is large and I need to share my metadata and data( which are private). All I can share was the pl file.
I did my best to figure out the origin of the problem and found the lines from the source code. Please help me to solve this problem cause I already lost so much time on this
Please use code blocks for code. You can put three ticks on a line before and after the lines of code. There should be a stickied post about how to use markdown on Discourse
In parallel to figuring out the markdown on Discourse, try to narrow down your problem. This is a necessary first step to reporting it. As @j4n_bur53 suggested, you can try to use bisection of your code, among other things. Once you create a minimal reproducible example you can share, it becomes possible for others to reproduce your problem and troubleshoot it. You can increase the limit but it will only push the problem to a bigger input, not solve it, as @j4n_bur53 also explained.
You can also use sub_string/5, with either atom or string argument. This will also avoid adding to the atom table, if that is the cause of your problem:
?- sub_string(abc, 0, _, _, A).
A = "" ;
A = "a" ;
A = "ab" ;
A = "abc".
(I ran this on Windows, using the Windows Subsystem for Linux (WSL).)
Anyway, from a quick look at your code, you appear to be doing a backtracking search for a path through a graph (with the graph defined by arc/2 facts). This can quickly produce a huge amount of backtracking. How many facts are in the arc/2 predicate? How large are the strings (or atoms) that are given to sub_atom/5?
One more thing you can do, if you donât want to show your data, is to give the output of a call to jiti_list(user:_) (assuming your code is in the default user module).
Hi,
I am getting a feeling that nobody focuses on the lines pointed out in pl-buffer.c and pl-buffer.h.
Please can you focus on the solution. As you see, I am doing some path searches not String processing. I have ARCS and PATHS. I use â not " but when I pasted, somehow it looked different (as if I copied from a word doc.). The error message is below. I get this on larger data (meaning more number of arcs, in my case 38 arcs) not for smaller datasets (in my case 10 arcs). In the larger dataset I have some arcs starting with an alphabet continuing with numbers like â23_1â. The subatoms are needed to process that kind of arcs.
I hope this information becomes useful.
Many Thanks,
Ferda
SWI-Prolog: [FATAL ERROR: at Sat Jul 31 11:35:15 2021
Too many stacked strings]I am getting
This limit is there for a reason, we all assume. Maybe none of us truly understands the reason. With a reproducible example, it would be possible to establish that something that should obviously work is broken, and more importantly, know what it is. This way it is possible to fix it without violating the original reasoning behind this admittedly arbitrary limit.
Youâre making a large assumption that these lines are the cause of the problem and not merely a symptom. Because you cannot give a âminimal reproducible exampleâ, we are having to guess as to the cause.
@j4n_bur53 has suggested a way of finding the problem. You might want to modify that advice slightly, e.g.:
This might produce a lot of output, so you might wish to redirect the output to a file. I donât know how to do this on Windows; on Linux, Iâd do something like swipl ... 2>/tmp/msgs.
(Instead of using writeln/2, you might do: format(user_error, '~q~n', [1-path_generic(A,B,Path)])
etc.)