gui icon indicating copy to clipboard operation
gui copied to clipboard

Random GUI error during (new message% ...)

Open dwmuller opened this issue 5 years ago • 1 comments

DrRacket 7, running on Windows 10 version 1803

I've been working on a GUI program that needs to show a table of data, the columns of which change according to checkbox selections. The checkboxes are arranged in several groups, each of which has "All" and "None" buttons to allow quick checking and clearing of all buttons in that group.

If I stress the program a bit by punching checkboxes and buttons more or less randomly, it eventually fails.

I was able to come up with a smaller, self-contained program that exhibits the same behavior. I've attached it to this message.

failure.rkt.txt

Running it from the command line with errortrace gives the most information.

$ racket -l errortrace -t failure.rkt
ptr-ref: contract violation
  expected: (and/c cpointer? (not/c (lambda (p) (pointer-equal? p #f))))
  given: #f
  argument position: 1st
  other arguments...:
   #<ctype:scheme>
  errortrace...:
   C:\Users\danm\Documents\Racket\NMSRecipes\failure.rkt:124:6: (new message% (parent column) (label (number->string item)))
   C:\Users\danm\Documents\Racket\NMSRecipes\failure.rkt:123:4: (for ((item column-data)) (new message% (parent column) (label (number->string ....))))
   C:\Users\danm\Documents\Racket\NMSRecipes\failure.rkt:130:4: (make-column (format "Column ~a" i) (list-ref column-data i))
   C:\Users\danm\Documents\Racket\NMSRecipes\failure.rkt:129:2: (for ((i selected-indexes)) (make-column (format "Column ~a" i) (list-ref column-data i)))

Sometimes it can take a while to get the error; it's quite random. Clicking the All and None buttons repeatedly will eventually cause it.

I'm usually running it in DrRacket, but I've also tried it as a standalone executable, with the same result.

The DrRacket IDE isn't quite right after this happens, either. The program will fail (with the same error) immediately, if I can even restart it. Sometimes a separate black window opens, showing a similar error. The IDE usually cannot be exited normally. Most of the text editing functions still work, though.

An earlier variant of the test program called show-selected-columns directly instead of via queue-callback. It seems like the error is a little easier to produce that way.

dwmuller avatar Oct 15 '18 01:10 dwmuller

The problem is that racket/gui is running out of Windows-level "user handles" for to implement GUI windows, and it runs out because a full GC isn't triggered often enough to finalize windows that have been removed. And since DrRacket runs in the same process, it can't create windows, either.

The racket/gui library should avoid this problem by forcing a GC as needed, and it should fail with a clear error message when the problem is that a resource has been exhausted.

Longer term, maybe racket/gui could associate a lower limit to a custodian, so that a program running in DrRacket cannot use up everything and cause DrRacket itself to fail.

mflatt avatar Oct 15 '18 15:10 mflatt