|Subject:||BUG: Segmentation error when printing to stream chars.|
|Date:||Sat, 14 Dec 2013 17:38:19 +0000|
I am starting a tiny HTTP client library after completing my Redis thing as I want to make a server and things like that and as usual, along the way, a gremlin has appeared!
Here is the *faulty* code:
when I run this from the REPL it blows when I try to display X in this query:
| ?- testing(V), format(‘~s~n',[V]).
Fatal Error: Segmentation Violation (bad address: 0x10)
I examined my code and I realised that after closing the output stream I had not restored the default stream back to user_output. This appears to be the cause of the blowout. If I run this modified code:
This works as expected:
| ?- testing(C), format('~s~n',[C]).
C = [71,69,84,32,47,109,121,47,115,108,105,112,112,101,114,115,47,110,111,119,47,106,101,101,118,101,115,13,10]
In the documentation for close/2, close/1 it says:
If SorA is the current output stream the current output stream becomes the standard output stream user_output.
I couldn’t determine what close_output_codes_stream/2 does and so it would seem that the user_output stream was in some indeterminate value?
Hope that helps track it down.
Many thanks again to Daniel and his Elves for GNU Prolog and a Merry Christmas everybody out there that buys into that particular scheme etc.
|[Prev in Thread]||Current Thread||[Next in Thread]|