gprolog blows on OSX with segmentation violation (bad address: 0x0)

Sean Charles <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
Hi, 

I was refactoring some code for a Redis client I am writing (INFO, KEYS and SET/GET currently working) and I managed to do something that made gprolog blow. It happens every time with this code:

gpredis_exec(Req) :-
	Req =.. [Cmd|Args],
	format('Command: ~a~n', [Cmd]),
	format('   Args: ~w~n', [Args]),
	gpredis_cmdargs(Args, Args2),
	flatten(Args2, Args3),
	format('Flatted: ~s~n', [Args3]).

gpredis_cmdargs([], []).
gpredis_cmdargs([Arg|Args], [Term|Output]) :-
	gpredis_stringify(Arg,X),
	format_to_codes(Term, 'term: ~w ', [X]),
	gpredis_cmdargs(Args, Output).

gpredis_stringify(X,Y) :- is_list(X), format_to_codes(Y, '~s~', [X]).
gpredis_stringify(X,Y) :- format_to_codes(Y, '~w', [X]).

and the session:
Seans-iMac:gprolog-redis seancharles$ gprolog
GNU Prolog 1.4.4 (64 bits)
Compiled Oct 13 2013, 17:19:55 with cc
By Daniel Diaz
Copyright (C) 1999-2013 Daniel Diaz
| ?- [exec].
compiling /Users/seancharles/Documents/github/gprolog-redis/exec.pl for byte code...
/Users/seancharles/Documents/github/gprolog-redis/exec.pl compiled, 17 lines read - 2455 bytes written, 4 ms

(1 ms) yes
| ?- gpredis_exec(test(100,'tonne',"century")).
Command: test
   Args: [100,tonne,[99,101,110,116,117,114,121]]

Fatal Error: Segmentation Violation (bad address: 0x0)

and my machine:
Darwin Seans-iMac.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64
Presumably that 0x0 is a null pointer somewhere!

I don’t have the capabilities to debug this level of problem, sorry but at least if/when this is fixed GNU Prolog will be all the better for a bit more Nietzsche-fication!

Thanks again,
Sean.

_______________________________________________
Users-prolog mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/users-prolog
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.