Hi,

First off would like to say thanks to the authors of gprolog for a great
prolog implementation and an nice cross-platform distribution.

I'm working on a text adventure game as a personal project, using prolog for
the game logic, and C++/Qt for the UI.

The plan is to release it on Mac (my main development platforrm), Windows (I
run XP in a VM just for this purpose) and Linux.  My day job is writing C++
code, and I know my way around compilers.

As soon as I got past first base, with some game logic and a UI working, I
wanted to build a release on all platforms to make sure things are all
working.

But while things work well on Mac - after a couple of teething problems -
I'm stuck with a crash bug on Windows.

The problem is occurring in my "do_command" function when I call
Pl_Query_Call:

extern "C" void do_command(const char *command)
{
    int func;
    int res;
    PlTerm arg[512];
    char cmd[512];
    PlTerm list;

    func = Find_Atom("do_command");

    if (func)
    {
        Pl_Query_Begin(PL_TRUE);
        i = 0;
        k = 0;
        list[0] = NULL;
        while (command[i])
        {
            /* parse each token out into cmd */
            arg[k++] = Mk_String(cmd);
        }
        if (k)
            list = Mk_Proper_List(k, arg);
        res = Pl_Query_Call(func, 1, list);
        while (res)
            res = Pl_Query_Next_Solution();
        Pl_Query_End(PL_RECOVER);
    }
}

I've cut out some detail but the full source code is here:
http://gitorious.org/ethex2040/ethex2040/blobs/master/prolog.cpp#line43

I compiled gprolog from source so I could use it in debug mode, but the
stack trace is not helpful.  At least it shows the site of the crash.

When the above function processes a command, I get a SIGSEGV crash on line
69 of file unify.c in the function Pl_Unify:

Bind_UV(u_adr, v_word)

I presume there's something wrong with the u_adr pointer.  But the other
frames in the stack are assembler and so far I'm mystified as to how to
trace what is going wrong.

Any ideas?

Regards,

Sarah Smith
_______________________________________________
Users-prolog mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/users-prolog

Reply via email to