amzi prolog + eclipse question - prolog

hey guys i have a question regarding amzi prolog with eclipse,
Im running a .pro file which executes a breadth first search and if queue gets too long,
the following error message appears:
system_error 1021 Control stack full.
Compile code or increase .cfg
parameter 'control'
If so, how may i run the compiled code under eclipse? I've tried running the project but the listener just ends without accepting any queries....?

Control stack full means one of two things:
You have a deep recursion that exhausts the control stack. In that case you need to increase the default value of 'control' in your amzi.cfg file. You may find you that have to increase 'heap', 'trail' and/or 'local' as well.
You have an error in your program causing an infinite recursion.
Running the program in the debugger will show you which case you've got. In the initial case you will see it digging deeper and deeper for a solution. In the later case you will see it chasing it's tail in circles with each recursion the same as the one before, but with different variables.

I don't know amzi prolog (I only used SICStus and SWI), and never used Eclipse for prolog, but as the error message says, try compiling (instead of consulting) your code. Look under project/properties for build configurations (like run/deug, as it works for Java/C++). Hopefully, that ".cfg paramerer" can also be accessed through project/properties.

Related

Xdebug: how to break program when a certain output occurs?

When debugging a PHP program with Xdebug, is it possible to set a kind of "conditional breakpoint" not on a specific line, but rather when a certain output is echoed?
This output could be specified by a certain string like id="someid" or by a regexp like id="header(1|2)".
I believe this would be extremely practical when debugging - I know something is wrong with some part of my output, and I want to break the program at the point where it is produced, so I can work up the Call Stack and see what went wrong.
I am using PhpStorm and I would be satisfied by an answer explaining how to do that in this particular IDE. But since I suspect it won't be possible, I ask the question in more generic terms: would Xdebug allow for this?

GNAT Ada runtime Exception = message EXCEPTION_STACK_OVERFLOW

I'am trying to run my application after compiling it with AdaCores GPS (Gnat Programming Studio).
I get the run time error
Exception name: STORAGE_ERROR
Message: EXCEPTION_STACK_OVERFLOW
I get these run time errors despite setting the stack size in the binder options using
-d65535 (task stack size) and
-D65535 (secondary stack size)
(I also have tried 65535k on both as well as 655m).
The application runs well when compiling it with the Aonix Object Ada compiler. In the Aonix compiler I set the
- stack size to 65535,
- the secondary stack size to 65535
- and the Task stack size to 46345.
My main aim is to port the application to the GNAT Ada compiler.
I notice -d sets the task stack size and -D the secondary stack size but I can't see where to set the main stack size, and I am assuming that this is the issue with the application, but please correct me if I am looking in the wrong direction.
Any pointers would be greatly appreciated appreciated.
Bearslumber
If the problem is indeed the main task, a workaround is to move the main procedure to the body of a helper task.
First, compile for debug (-g) (there may be other relevant options; posting wrong information is the fastest way to find them ;-) and you should get more information : the source line and file that raised the exception. Or a stack trace which you can analyze via addr2line.
That should help understand why it is raising...
Are you allocating hundreds of MB on the stack? I've got away with about 200MB in the past...
Is the raise within one of the container classes or part of the RTS?
Is the message actually misleading and a new() heap allocation failed? Other things than the stack can raise Storage_Error, and I'm not clear how or if the default handler distinguishes the cause...
We can't proceed further down this path without further information : edit it into the question and I'll take another look.
Setting stack size for the environment task is not directly possible within Gnat. It's part of gcc's interaction with the OS, and supposed to use the system's ulimit settings for the resulting executable (on Linux; other OS may vary)...
Unfortunately, around the gcc/gnat 4.5 timeframe I found evidence these were being ignored, though that may have been corrected, and I haven't revisited that problem.
I have seen Alex's answer posted elsewhere as a viable workround if the debug trace and ulimit settings don't provide the answer, or if you need to press on instead of spending time debugging. To keep the codebase clean, I would suggest a wrapper, simply creating the necessary task and calling your current main procedure. For Aonix you simply don't need to include the wrapper file in your build.

How to bypass "stack level too deep (SystemStackError)" Error

(using OS X 10.9.4) I have this cool Ruby script which scans system/firewall logs and tells me if anything odd is happening. The script runs on a 1 second loop, however at exactly the 3852nd iteration, the script terminates with a "stack level too deep (SystemStackError)" error.
I am not new to this error and it seems to appear when a script enters a loop, and the system sandbox (probably) terminates it after a set amount of time or a specific parameter is reached.
I attempted to bypass the error by running the script as root, however this had no effect. I have also considered programming another script to relaunch the original script when it detects its absence in the command: ps -efs' output, however this is a very 'clunky' method which i would prefer to avoid.
I have also conducted some research into the error on the "Stack Overflow", however only found questions answered by altering the offending script ,as the error is in their case due to a bug in the code, which is not the case for me.
So my question:
Is there any possible way to bypass the "stack level too deep (SystemStackError)" error
Thanks in advance, greatly appreciated.

Difficulties compiling fortran .f95 file, how to debug?

I am trying to learn fortran. I wanted to replicate a certain step in a paper but I ran into trouble.
I compiled the file AERsimulation.f95 (I turned on all debugging functions in gfortran I am aware of) I could generate an .out file without any errors (a lot of warnings, however...)
When I tried to run the .out file I got the error message
Fortran runtime error: Index '0' of dimension 1 of array 'k' below lower bound of 1
Now, it is quite difficult for me to understand why exactly this happens. I guess, my question is, whether there is a better way of debugging, so that I can see and click through the code 'live' and see why the error occurs. (I am thinking of the matlab-debugger for instance...)
Any suggestion/hint is very welcome
The files I use are
AERsimulation.f95
AERDATANB.TXT
Thank you very much
Best
Derrick
The meaning of your error message is that you try to access an array element at the position 0 of the array. Arrays in Fortran start at 1 by default.
If you are looking for a better way to debug, try gdb (command line) or if you prefer a graphical interface you can try the Netbeans IDE. It has (limited) support for Fortran an a debugging mode where you can click line by line through the code and see the values of all variables and so on.
On command line try:
gdb name_of_executable
run
the debugger will stop at the line which causes the error.

Increase stack size in ECLiPSe/prolog/fd

We have to solve the liars problem in prolog, in several environments with constraints (ECLiPSe ic, ECLiPSe fd, SWI-prolog, GNU-prolog, NaxosSolver, etc.). I have used tail recursion (I think) and as many cuts as I could think of(that way I guess the resolution tree is not getting as big as it could be. If requested, I can post my code.
When the data number becomes 10000-50000, I receive a stack overflow in fd and ic in ECLiPSe and in SWI-prolog the program runs forever. So I would like to increase the size of the stack in ECLiPSe, but I can not see how.
I tried to write in the 1st line of my code this:
:-set_flag(local_stack_allocated, 512).
, but it says out of range.
See what eclipse says, which might be helpful:
* Overflow of the global/trail stack in spite of garbage collection!
You can use the "-g kBytes" (GLOBALSIZE) option to have a larger stack.
Peak sizes were: global stack 128832 kbytes, trail stack 5312 kbytes
First, from error message text I'm assuming that you mean ECLiPSe constraint logic programming system, not Eclipse IDE.
Second, how do you start ECLiPSe? How do you load your code into ECLiPSe?
Try this (you said you are on Windows):
Open command line from the folder where your ECLiPSe source file (say, 'myprogram.ecl') exists. For instructions look at this page: http://www.techsupportalert.com/content/how-open-windows-command-prompt-any-folder.htm
In the command line put eclipse -g 512000 and press ENTER.
Load your program using [myprogram]. (put name of your ECLiPSe source file instead of 'myprogram').
Execute queries as usual.
But I suspect that your program just runs forever and eats all memory, so all this probably won't help in the end.
EDIT. Updated instructions for TkECLiPSe:
In TkECLiPSe in menu choose Tools -> TkECLiPSe Preference Editor.
In preference window find option "Global/trail stack size (in megabytes)" and set it to 512.
Save preferences and close TkECLiPSe.
Next time you run TkECLiPSe stack size will be set to 512 Mb.

Resources