Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace process with typed-process #23

Open
jwaldmann opened this issue Mar 17, 2021 · 1 comment
Open

replace process with typed-process #23

jwaldmann opened this issue Mar 17, 2021 · 1 comment

Comments

@jwaldmann
Copy link

I am getting spurious smtlib2: unknown check-sat response: ""

might be solved with https://github.com/fpco/typed-process

e.g., I am doing this here https://gitlab.imn.htwk-leipzig.de/waldmann/pure-matchbox/-/blob/master/src/Ersatz/Solver/Pipe.hs

jwaldmann added a commit to jwaldmann/smtlib2 that referenced this issue Mar 18, 2021
@jwaldmann
Copy link
Author

this unknown check-sat response "" may actually be in instance of clearInput not working. I added this remark/question to the source:

-- I THINK this will pull characters from the solver's output
-- (that we will ignore) until it blocks.
-- E.g., a solver may send newlines and comments (traces, timing)
-- The problem is that the solver may be slow in sending a comment
-- (temporarily blocking) so we assume it's done,
-- and mistake a slow comment for an actual response.
clearInput :: SMTPipe -> IO ()
clearInput pipe = do
  let stdout = getStdout $ processHandle pipe
  r <- hReady stdout
  if r
    then (do
             _ <- BS.hGetSome stdout 1024
             clearInput pipe)
    else return ()

putRequest :: SMTPipe -> L.Lisp -> IO ()
putRequest pipe expr = do
  clearInput pipe -- we pull the character stream until it blocks.
  -- then we send the request. so we can be sure that the following characters
  -- are indeed from the response to this request.
  let stdin = getStdin $ processHandle pipe
  toByteStringIO (BS.hPutStr stdin) (mappend (L.fromLispExpr expr) flush)
  BS8.hPutStrLn stdin ""
  hFlush stdin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant