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

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

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

emacstheviking
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
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog
Reply | Threaded
Open this post in threaded view
|

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

Alexandre Saidi
Dears,
If that can help, I ran the example with gprolog  1.4.0 (on an Imac) and got this messages :
| ?- gpredis_exec(test(100,'tonne',"century")).
Command: test
   Args: [100,tonne,[99,101,110,116,117,114,121]]
uncaught exception: error(domain_error(format_control_sequence,''),format_to_codes/3)


A trace gave (the last part of the trace) :

10    4  Call: gpredis_stringify(tonne,_613) ? 
     11    5  Call: is_list(tonne) ? 
     11    5  Fail: is_list(tonne) ? 
     11    5  Call: format_to_codes(_640,'~w',[tonne]) ? 
     11    5  Exit: format_to_codes([116,111,110,110,101],'~w',[tonne]) ? 
     10    4  Exit: gpredis_stringify(tonne,[116,111,110,110,101]) ? 
     12    4  Call: format_to_codes(_573,'term: ~w ',[[116,111,110,110,101]]) ? 
     12    4  Exit: format_to_codes([116,101,114,109,58,32,91,49,...],'term: ~w ',[[116,111,110,110,101]]) ? 
     13    4  Call: gpredis_cmdargs([[99,101,110,116,117,114,121]],_574) ? 
     14    5  Call: gpredis_stringify([99,101,110,116,117,114,121],_786) ? 
     15    6  Call: is_list([99,101,110,116,117,114,121]) ? 
     15    6  Exit: is_list([99,101,110,116,117,114,121]) ? 
     16    6  Call: format_to_codes(_837,'~s~',[[99,101,110,116,117,114,121]]) ? 
.....
      1    1  Exception: gpredis_exec(test(100,tonne,[99,101,110,116,117,114,121])) ? 
uncaught exception: error(domain_error(format_control_sequence,''),format_to_codes/3)

But no segmentation error for me.


I think you can see the reason.
Alex





Le 17 nov. 2013 à 16:00, Sean Charles a écrit :

gpredis_exec(test(100,'tonne',"century")).

---------------------- IMAP --------------------
Alexandre Saidi
Maitre de Conférences (Ass Pr.)
Ecole Centrale de Lyon
Dép. Mathématiques - Informatique
LIRIS-CNRS UMR 5205
Tél : 0472186530, Fax : 0472186443



_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog
Reply | Threaded
Open this post in threaded view
|

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

Daniel Diaz-3
In reply to this post by emacstheviking
Dear Sean,

as you noted the final ~ is wrong, it should be ~n. I have anyway fixed the implementation to report an error on such case.
The fix is available in the git.

Daniel

Le 17/11/2013 16:00, Sean Charles a écrit :
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.


--
Ce message a été vérifié par MailScanner pour des virus ou des polluriels et rien de suspect n'a été trouvé.

_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog


--
Ce message a été vérifié par MailScanner pour des virus ou des polluriels et rien de suspect n'a été trouvé.
_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog
Reply | Threaded
Open this post in threaded view
|

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

emacstheviking
Daniel,

Thanks as always. I will rebuild my version tonight.

A while back I was playing with dlload() et al. and you mentioned that there was some work in progress (?) about having a module loading system...is that still the case or is there just not enough time in the day for such things?

All the best,
Sean.



On 21 November 2013 08:03, Daniel Diaz <[hidden email]> wrote:
Dear Sean,

as you noted the final ~ is wrong, it should be ~n. I have anyway fixed the implementation to report an error on such case.
The fix is available in the git.

Daniel

Le 17/11/2013 16:00, Sean Charles a écrit :
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.


--
Ce message a été vérifié par MailScanner pour des virus ou des polluriels et rien de suspect n'a été trouvé.

_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog


--
Ce message a été vérifié par MailScanner pour des virus ou des polluriels et rien de suspect n'a été trouvé.


_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog
Reply | Threaded
Open this post in threaded view
|

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

Paulo Moura-2

On 21/11/2013, at 09:42, emacstheviking <[hidden email]> wrote:

> Daniel,
>
> Thanks as always. I will rebuild my version tonight.
>
> A while back I was playing with dlload() et al. and you mentioned that there was some work in progress (?) about having a module loading system...is that still the case or is there just not enough time in the day for such things?

You can write Prolog module code today using Logtalk. Supported module directives include module/2, use_module/2, export/1, and reexport/2. But you will need to use .lgt instead of .pl as the filename extension and Logtalk's compiling and loading predicates. You can later change the extension back when Daniel releases a GNU Prolog version with modules support.

Cheers,

Paulo

-----------------------------------------------------------------
Paulo Moura
Logtalk developer

Email: <mailto:[hidden email]>
Web:   <http://logtalk.org/>
-----------------------------------------------------------------





_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog