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

Invalid dap result from ghci #18

Open
malte-v opened this issue Jul 2, 2020 · 5 comments
Open

Invalid dap result from ghci #18

malte-v opened this issue Jul 2, 2020 · 5 comments

Comments

@malte-v
Copy link

malte-v commented Jul 2, 2020

Hey there, thanks for making this extension! I'm having some trouble getting it to work.

My app is a warp server that is accessed from a web browser. I'm able start debugging without any problems:

Configuration read.
Starting GHCi.
Wait for a moment.

CWD: /home/malte/testing/reflex-stack
CMD: stack ghci --with-ghc=ghci-dap --test --no-load --no-build --main-is app --ghci-options -fprint-evld-with-show

Now, waiting for an initial prompt("> ") from ghci.

Configuring GHCi with the following packages: app, backend, common, frontend
[DAP][INFO] start ghci-dap-0.0.14.0.
GHCi, version 8.8.3: https://www.haskell.org/ghc/  :? for help
>:set prompt "<<DAP_CMD_END2>>\nH>>= "
H>>= :set prompt-cont "<<DAP_CMD_END2>>\nH>>= "
H>>= :dap-launch ...
H>>= :load /home/malte/testing/reflex-stack/app/Main.hs
[1 of 6] Compiling Common.API       ( /home/malte/testing/reflex-stack/common/src/Common/API.hs, interpreted )
[2 of 6] Compiling Backend          ( /home/malte/testing/reflex-stack/backend/src/Backend.hs, interpreted )
[3 of 6] Compiling Frontend.API     ( /home/malte/testing/reflex-stack/frontend/src/Frontend/API.hs, interpreted )
[4 of 6] Compiling Frontend.Router  ( /home/malte/testing/reflex-stack/frontend/src/Frontend/Router.hs, interpreted )
[5 of 6] Compiling Frontend         ( /home/malte/testing/reflex-stack/frontend/src/Frontend.hs, interpreted )
[6 of 6] Compiling Main             ( /home/malte/testing/reflex-stack/app/Main.hs, interpreted )
Ok, six modules loaded.
H>>= :dap-context-modules ...
H>>= :dap-set-function-breakpoints ...
H>>= :set -fno-break-on-exception
H>>= :set -fno-break-on-error
H>>= :dap-continue ...
Running on https://localhost:8080

... but when my app gets an HTTPS request from the browser, the debugger exits with the following message:

Running on https://localhost:8080 ^^^ from above
[CRITICAL][APP] invalid dap result from ghci. ["Running on https://localhost:8080"]

Here are the contents of the log file and my launch.json:

2020-07-02 15:40:22.642090197000 [43274(ThreadId 9)] CRITICAL APP - invalid dap result from ghci. ["Running on https://localhost:8080"]
2020-07-02 15:40:23.087097425000 [43274(ThreadId 12)] CRITICAL THREAD_MGR - Critical exit started.
{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "ghc",
      "request": "launch",
      "name": "Haskell",
      "internalConsoleOptions": "openOnSessionStart",
      "workspace": "${workspaceFolder}",
      "startup": "${workspaceFolder}/app/Main.hs",
      "startupFunc": "",
      "startupArgs": "",
      "stopOnEntry": false,
      "mainArgs": "",
      "ghciPrompt": "H>>= ",
      "ghciInitialPrompt": "> ",
      "ghciCmd": "stack ghci --test --no-load --no-build --main-is app --ghci-options -fprint-evld-with-show",
      "ghciEnv": {},
      "logFile": "${workspaceFolder}/.vscode/debugger.log",
      "logLevel": "WARNING",
      "forceInspect": false
    }
  ]
}

I've tried not printing the "Running on https://localhost:8080" message, but then I get the following error after reloading the browser:

[CRITICAL][APP] invalid dap result from ghci. []

So I don't think this is the culprit. I've installed these versions of the tools mentioned in the VSCode extension README:

➜  ~ ghci-dap --version
[DAP][INFO] start ghci-dap-0.0.14.0.
The Glorious Glasgow Haskell Compilation System, version 8.8.3
➜  ~ haskell-debug-adapter --version
haskell-debug-adapter-0.0.33.0

Any idea what could have gone wrong here? Thanks!

@phoityne
Copy link
Owner

phoityne commented Jul 3, 2020

Hi.

[CRITICAL][APP] invalid dap result from ghci. []

This seems that haskell-debug-adapter lost stdio handle to ghci-dap.

Could you run these commands from the console?
and let me know the console result.

> cd /home/malte/testing/reflex-stack
> stack ghci --with-ghc=ghci-dap --test --no-load --no-build --main-is app --ghci-options -fprint-evld-with-show
...
...
Prelude> :load /home/malte/testing/reflex-stack/app/Main.hs
Prelude> :trace main
...
...
gets an HTTPS request from the browser.

I tried to reproduce with a servant app, but could't.

@malte-v
Copy link
Author

malte-v commented Jul 3, 2020

➜  reflex-stack git:(master) ✗ stack ghci --with-ghc=ghci-dap --test --no-load --no-build --main-is app --ghci-options -fprint-evld-with-show
Configuring GHCi with the following packages: app, backend, common, frontend
[DAP][INFO] start ghci-dap-0.0.14.0.
GHCi, version 8.8.3: https://www.haskell.org/ghc/  :? for help
> :load /home/malte/testing/reflex-stack/app/Main.hs
[1 of 6] Compiling Common.API       ( /home/malte/testing/reflex-stack/common/src/Common/API.hs, interpreted )
[2 of 6] Compiling Backend          ( /home/malte/testing/reflex-stack/backend/src/Backend.hs, interpreted )
[3 of 6] Compiling Frontend.API     ( /home/malte/testing/reflex-stack/frontend/src/Frontend/API.hs, interpreted )
[4 of 6] Compiling Frontend.Router  ( /home/malte/testing/reflex-stack/frontend/src/Frontend/Router.hs, interpreted )
[5 of 6] Compiling Frontend         ( /home/malte/testing/reflex-stack/frontend/src/Frontend.hs, interpreted )
[6 of 6] Compiling Main             ( /home/malte/testing/reflex-stack/app/Main.hs, interpreted )
Ok, six modules loaded.
*Main> :trace main
Running on https://localhost:8080
# gets HTTPS request
[1]    20518 segmentation fault (core dumped)  stack ghci --with-ghc=ghci-dap --test --no-load --no-build --main-is app

Here is the code, if you want to try to reproduce the issue: https://github.com/malte-v/reflex-stack/tree/739f8bd8466c65be9e6ae75ce3a3acf65a22690a As stated in the README, you need to run tools/certify. It's ok to just always press enter when it asks for information. You also can skip adding the CA to your browser and just dismiss the usual warning about the invalid certificate. Thanks for looking into this!

@malte-v
Copy link
Author

malte-v commented Jul 3, 2020

This seems to be SSL-specific, which is probably why you couldn't reproduce the issue:

➜  ~ curl -v --insecure https://localhost:8080                                                         
*   Trying ::1:8080...
* connect to ::1 port 8080 failed: Connection refused
*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to localhost:8080 
* Closing connection 0
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to localhost:8080 

When running regularly (not inside the debugger):

➜  ~ curl -v --insecure https://localhost:8080
*   Trying ::1:8080...
* connect to ::1 port 8080 failed: Connection refused
*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=AU; ST=Some-State; O=self-signed localhost certificate
*  start date: Jul  1 16:51:37 2020 GMT
*  expire date: Oct  4 16:51:37 2022 GMT
*  issuer: C=AU; ST=Some-State; O=malte
*  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x563291dc78b0)
> GET / HTTP/2
> Host: localhost:8080
> user-agent: curl/7.70.0
> accept: */*
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
< HTTP/2 200 
< date: Fri, 03 Jul 2020 14:03:54 GMT
< server: Warp/3.3.12
< content-type: text/html
< 
<!DOCTYPE html>
<html>
<head>
<title>JSaddle</title>
</head>
<body>
</body>
<script src="/jsaddle.js"></script>
</html>
* Connection #0 to host localhost left intact

@malte-v
Copy link
Author

malte-v commented Jul 3, 2020

I can confirm that the issue does not occur when using HTTP.

@phoityne
Copy link
Owner

phoityne commented Jul 3, 2020

What is your OS environment ?
Could you run these commands from console ?
(without ghci-dap, running original ghci.)

> cd /home/malte/testing/reflex-stack
> stack ghci --test --no-load --no-build --main-is app --ghci-options -fprint-evld-with-show
...
...
Prelude> :load /home/malte/testing/reflex-stack/app/Main.hs
Prelude> :trace main
...
...
gets an HTTPS request from the browser.

Regards.

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

2 participants