[racket] non-terminating type check for typed racket

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Sun Apr 17 19:36:02 EDT 2011

On Sun, Apr 17, 2011 at 6:10 PM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:
> On Sun, Apr 17, 2011 at 3:04 PM, Danny Yoo <dyoo at cs.wpi.edu> wrote:
>> This behavior appears for both Racket 5.0.1 as well as Racket 5.1.
>> I've git tagged my project as 'infinite-typecheck' at the point where
>> I'm seeing this behavior.
>>
>>    https://github.com/dyoo/js-sicp-5-5/tree/infinite-typecheck
>
> We'll take a look, but a reduced test case would be very nice ...


Ok, so I no longer think this is an infinite loop issue anymore.
However, there's definitely something nonlinear going on.  I'm editing
il-structs.rkt and modifying the PrimitiveCommand type union.


When I reduce the union to:

(define-type PrimitiveCommand (U
                               CheckToplevelBound!
                               CheckClosureArity!
                               CheckPrimitiveArity!

                               ExtendEnvironment/Prefix!
                               InstallClosureValues!
                               FixClosureShellMap!

                               InstallContinuationMarkEntry!

                               SetFrameCallee!
                               SpliceListIntoStack!
                               UnspliceRestFromStack!

                               #;RaiseContextExpectedValuesError!
                               #;RaiseArityMismatchError!
			       #;RaiseOperatorApplicationError!

                               RestoreEnvironment!
                               RestoreControl!))


and try to compile assemble.rkt, I see the following times (assuming
all the other dependencies have been previously compiled):

##########################################################
dyoo at thunderclap:~/work/js-sicp-5-5$ time raco make assemble.rkt

real	0m14.171s
user	0m13.977s
sys	0m0.196s
##########################################################


So, about fourteen seconds to compile.  Now, If I uncomment
RaiseOperatorApplicationError! and try to recompile, the time doubles!


dyoo at thunderclap:~/work/js-sicp-5-5$ time raco make assemble.rkt

real	0m29.513s
user	0m29.334s
sys	0m0.212s


If I uncomment RaiseArityMismatchError! and
RaiseOperatorApplicationError!, I do end up with the compilation
finishing (and giving me an expected type error), but the time has
gone up dramatically to 1 minute, 20 seconds:

#####################################################
dyoo at thunderclap:~/work/js-sicp-5-5$ time raco make assemble.rkt
assemble.rkt:608:29: Type Checker: Wrong number of arguments, expected
1 and got 0 in: (RaiseArityMismatchError!-received)

 === context ===
/home/dyoo/local/plt-5.0.1/collects/typed-scheme/typecheck/tc-toplevel.rkt:248:0:
type-check
/home/dyoo/local/plt-5.0.1/collects/racket/contract/private/arrow.rkt:1445:3
/home/dyoo/local/plt-5.0.1/collects/compiler/cm.rkt:269:0: compile-zo*
/home/dyoo/local/plt-5.0.1/collects/compiler/cm.rkt:406:42
/home/dyoo/local/plt-5.0.1/collects/compiler/cm.rkt:371:0: maybe-compile-zo
/home/dyoo/local/plt-5.0.1/collects/compiler/cm.rkt:465:2: do-check
/home/dyoo/local/plt-5.0.1/collects/compiler/cm.rkt:539:4
/home/dyoo/local/plt-5.0.1/collects/compiler/commands/make.rkt:62:8: for-loop
/home/dyoo/local/plt-5.0.1/collects/compiler/commands/make.rkt: [running body]
/home/dyoo/local/plt-5.0.1/collects/raco/raco.rkt: [running body]
/home/dyoo/local/plt-5.0.1/collects/raco/main.rkt: [running body]


real	1m21.405s
user	1m21.249s
sys	0m0.200s
#####################################################


I have to do some other work at the moment, but maybe this will help
guide discovery on what's happening.



Posted on the users mailing list.