racket / drracket

DrRacket, IDE for Racket
http://www.racket-lang.org/
Other
444 stars 93 forks source link

Install Package can hang and not return control #586

Closed shriram closed 1 year ago

shriram commented 1 year ago

I already had a Package Source URL and accidentally pasted a second one and hit enter, creating an erroneous URL. The installer says

Querying Git references for smol at https://github.com/LuKC1024/stacker.githttps://github.com/shriram/smol.git
pkg: Git checkout initial protocol failed;
 the given URL might not refer to a Git repository
  given URL: https://github.com/LuKC1024/stacker.githttps://github.com/shriram/smol.git
  context...:
   /Applications/Racket v8.6/collects/pkg/private/stage.rkt:782:25
   /Applications/Racket v8.6/collects/net/git-checkout.rkt:382:0: parse-initial-refs
   /Applications/Racket v8.6/collects/net/git-checkout.rkt:74:8
  [several lines elided]
   ...

Clicking "Abort Install" results in

Aborted.

being printed. However, it doesn't actually abort. I can click it multiple times; each one results in another print. But Abort Install is still active, Close is disabled, and if I fix the URL and click Install again, I get an error pop-up:

Installation and updating cannot happen simultaneously; either abort the current one or wait for it to finish.

Since this is a modal window, there is no way to return control to DrRacket. It looks like the only option is to Force Quit.

DrRacket: v8.6 ARM version OS: macOS Monterey 12.5.1 Hardware: MacBook Air M2 chip

rfindler commented 1 year ago

I'm not able to get the bad behavior (same architecture, almost the same OS (12.6, not 12.5)). When I just click install I get

Querying Git references for smol at https://github.com/LuKC1024/stacker.githttps://github.com/shriram/smol.git
pkg: Git checkout initial protocol failed;
 the given URL might not refer to a Git repository
  given URL: https://github.com/LuKC1024/stacker.githttps://github.com/shriram/smol.git
  context...:
   /Users/robby/git/exp/plt/racket/collects/pkg/private/stage.rkt:782:25
   /Users/robby/git/exp/plt/racket/collects/net/git-checkout.rkt:382:0: parse-initial-refs
   /Users/robby/git/exp/plt/racket/collects/net/git-checkout.rkt:74:8
   /Users/robby/git/exp/plt/racket/collects/net/git-checkout.rkt:55:2: retry-loop
   /Users/robby/git/exp/plt/racket/collects/pkg/private/stage.rkt:62:2: lookup-normally
   /Users/robby/git/exp/plt/racket/collects/pkg/private/stage.rkt:115:0: stage-package/info
   /Users/robby/git/exp/plt/racket/collects/pkg/private/install.rkt:142:0: install-packages
   /Users/robby/git/exp/plt/racket/collects/pkg/private/install.rkt:953:4
   /Users/robby/git/exp/plt/racket/collects/racket/contract/private/arrow-val-first.rkt:555:3
   /Users/robby/git/exp/plt/racket/collects/racket/file.rkt:763:8
   /Users/robby/git/exp/plt/racket/collects/racket/file.rkt:752:0: call-with-file-lock
   /Users/robby/git/exp/plt/racket/collects/pkg/main.rkt:223:16
   /Users/robby/git/exp/plt/racket/collects/racket/contract/private/arrow-higher-order.rkt:375:33
   /Users/robby/git/exp/plt/extra-pkgs/gui/gui-lib/mrlib/terminal.rkt:213:7
   /Users/robby/git/exp/plt/extra-pkgs/gui/gui-lib/mred/private/wx/common/queue.rkt:435:6
   /Users/robby/git/exp/plt/extra-pkgs/gui/gui-lib/mred/private/wx/common/queue.rkt:486:32
   ...

and a similar error message in 8.6. When I click quickly on the abort, I do see the aborted message, but I get the close button back.

I don't suppose you're still seeing this bad behavior?

rfindler commented 1 year ago

Actually, I do see it, but I have to try a few times to see it.

rfindler commented 1 year ago

Here's a smaller program that seems to mimic what's happening when a package is installed. It has the same bad behavior; the loop doesn't terminate by counting all the way down to 100 but gets stuck partway down. I'm not sure if this program is breaking something about how it uses in-terminal or not, or if there is a bug in in-terminal (or some lower layer), tho.

#lang racket/base
(require mrlib/terminal racket/class racket/gui/base)

(let loop ([n 100])
  (unless (zero? n)
    (printf "==================== ~s\n" n)
    (define dlg (new dialog% [label ""] [width 600] [height 800]))
    (queue-callback
     (λ ()
       (define t (in-terminal (λ args (car #f)) #:container dlg))
       (yield (send t can-close-evt))
       (send t close)
       (send dlg show #f)
       (loop (- n 1))))
    (send dlg show #t)))
rfindler commented 1 year ago

After some offline discussion with @mflatt who pointed out there is a subtle point with the semantics of thread-wait (and thread-dead-evt) that will require further thought and study to figure out, the best thing here is probably to just avoid using thread-wait and instead wait for the custodian installer-cust to be shutdown. It looks like whenever installer-thread dies, installer-cust also gets shutdown so that's a local change here that seems to fix things (the code in the comment above finishes all 100 iterations but never got through 10 that I saw without the fix; also, installing packages in drracket that complete successfully seems to work and the abort button also still seems to work).