[racket-dev] Can't Find a Workaround for Bug 11017 in DrRacket

From: Doug Williams (m.douglas.williams at gmail.com)
Date: Tue Jul 20 13:18:36 EDT 2010

I seem have hit the same (or related) bug that Laurent Orseau submitted as
bug 11017 (but in a completely different context that might help track it
down) and I haven't been able to find a workaround. The actual error message
I get is:

string<?: expects type <string> as 1st argument, given: #f; other arguments
were:
 "c29a751537a750b825f72c9ee37eea737a0f3a8b9cd41e2f58a86ac8158ca605f292b20a02896479"

coming from somewhere in the bowels of DrRacket. I don't get the error when
using Racket (i.e., MzScheme). I'm not sure if this machine was running the
stock V5.0 or a post-V5.0 nightly build that fixed a PLaneT problem I was
having. But, the pre-release 5.0.1 build gives the same error. I reloaded
V4.2.5 and the code runs fine there.

I was hoping that the string in the error message itself might give someone
in the know some idea of the problem.

Unfortunately, this happens in a rather large autogenerated agent-based
simulation that isn't easily posted - although I can send the code and the
development packages it uses to someone if they need it.

A short extract of the 'main' program that runs:

#lang scheme
;;; Agent Generation from Templates - PRIME (AGenT') by SET Corporation (an
SAIC Company)
;;; Autogenerated PLT Scheme source code
invest-in-pa-yangi-yangi-tucker---plausible-outcomes-212-main.ss
;;; Generated Monday, July 19th, 2010 12:33:42pm

(require (planet williams/madness/madness)

"invest-in-pa-yangi-yangi-tucker---plausible-outcomes-212-arguments.ss"

"invest-in-pa-yangi-yangi-tucker---plausible-outcomes-212-argument-values.ss"

"invest-in-pa-yangi-yangi-tucker---plausible-outcomes-212-data-collection.ss")

... <about 1300 SLOC redacted>

;;;
;;; Monte Carlo loop INVEST-IN-PA-YANGI-YANGI-TUCKER---PLAUSIBLE-OUTCOMES
;;;
(define (INVEST-IN-PA-YANGI-YANGI-TUCKER---PLAUSIBLE-OUTCOMES n)
  (with-new-simulation-environment
    (let ((aggregate-instance-index (make-hasheq)))
      (for ((i (in-range n)))
        (INVEST-IN-PA-YANGI-YANGI-TUCKER i aggregate-instance-index))
      (print-statistics aggregate-instance-index)
      (generate-exhibit-files aggregate-instance-index)
      (generate-results-XML aggregate-instance-index n))))

;;;
;;; Execute Monte Carlo
;;;

(INVEST-IN-PA-YANGI-YANGI-TUCKER---PLAUSIBLE-OUTCOMES 10)

;;;
;;; Module Contracts
;;;

(provide (all-defined-out))

If I simply remove the call to
(INVEST-IN-PA-YANGI-YANGI-TUCKER---PLAUSIBLE-OUTCOMES 10) and move it to
it's own package:

#lang scheme
;;; Agent Generation from Templates - PRIME (AGenT') by SET Corporation (an
SAIC Company)
;;; Autogenerated PLT Scheme source code
invest-in-pa-yangi-yangi-tucker---plausible-outcomes-212-monte-carlo.ss
;;; Generated Monday, July 19th, 2010 12:33:43pm

(require "invest-in-pa-yangi-yangi-tucker---plausible-outcomes-212-main.ss")


;;;
;;; Execute Monte Carlo
;;;

(INVEST-IN-PA-YANGI-YANGI-TUCKER---PLAUSIBLE-OUTCOMES 10)

I get the error above. [Again, it runs under Racket (i.e., MzScheme).]

Please let me know if there are some switches I can set or otherwise provide
additional information.

Ah, I just ran it with "No debugging or profiling" checked and got some
additional information - seems interesting that I got more information with
no debugging. But anyway the error printed is now

..\..\..\..\..\..\..\..\..\Program
Files\Racket\collects\racket\private\sort.rkt:85:19: string<?: expects type
<string> as 1st argument, given: #f; other arguments were:
"146047b7b2121bf8f7b15d7c2ef396b710f394474c12d02f2de08868342b8264c39b7fe111a38bf5"

It also gave a backtrace that I copied and pasted into the attached file.
[Was a better way to do that?]

Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20100720/461fa1ac/attachment.html>
-------------- next part --------------
?string<?: expects type <string> as 1st argument, given: #f; other arguments were:
 "146047b7b2121bf8f7b15d7c2ef396b710f394474c12d02f2de08868342b8264c39b7fe111a38bf5"

C:\Program Files\Racket\collects\racket\private\sort.rkt: 85:19 
                     (let jloop ([j (i+ Blo i)])
                     (let ([ref-j-1 (ref (i- j 1))])
                       (if (and (i< Blo j) (<? ref-i ref-j-1))
                         (begin (set! j ref-j-1) (jloop (i- j 1)))
                         (begin (set! j ref-i) (iloop (i+ i 1)))))))))))

C:\Program Files\Racket\collects\racket\private\sort.rkt: 213:0 
  (case-lambda
  [(lst <?) (sort-body lst <? #f #f #f)]
  [(lst <? getkey)
   (if (and getkey (not (eq? values getkey)))
     (sort lst <? getkey #f) (sort lst <?))]
  [(lst <? getkey cache-keys?)
   (if (and getkey (not (eq? values getkey)))
     (sort-body lst <? #t getkey cache-keys?) (sort lst <?))])

C:\Program Files\Racket\collects\compiler\cm.rkt: 177:0 
  (define (get-dep-sha1s deps up-to-date read-src-syntax mode must-exist?)
  (let ([l (for/fold ([l null]) ([dep (in-list deps)])
             (and l
                  ;; (cons 'ext rel-path) => a non-module file, check source
                  ;; rel-path => a module file name, check cache
                  (let* ([ext? (and (pair? dep) (eq? 'ext (car dep)))]
                         [p (main-collects-relative->path (if ext? (cdr dep) dep))])
                    (cond
                     [ext? (let ([v (get-source-sha1 p)])
                             (cond
                              [v (cons (cons (delay v) dep) l)]
                              [must-exist? (error 'cm "cannot find external-dependency file: ~v" p)]
                              [else #f]))]
                     [(or (hash-ref up-to-date (simple-form-path p) #f)
                          ;; Use `compiler-root' with `sha1-only?' as #t:
                          (compile-root mode p up-to-date read-src-syntax #t))
                      => (lambda (sh)
                           (cons (cons (cdr sh) dep) l))]
                     [must-exist?
                      ;; apparently, we're forced to use the source of the module,
                      ;; so compute a sha1 from it instead of the bytecode
                      (cons (cons (get-source-sha1 p) dep) l)]
                     [else #f]))))])
    (and l
         (let ([p (open-output-string)]
               [l (map (lambda (v) (cons (force (car v)) (cdr v))) l)])
           ;; sort by sha1s so that order doesn't matter
           (write (sort l string<? #:key car) p)
           ;; compute one hash from all hashes
           (sha1 (open-input-bytes (get-output-bytes p)))))))

C:\Program Files\Racket\collects\compiler\cm.rkt: 214:6 
        (lambda (op tmp-path)
        (let ([deps (append
                     (map path->main-collects-relative deps)
                     (map (lambda (x)
                            (cons 'ext (path->main-collects-relative x)))
                          external-deps))])
        (write (list* (version)
                      (cons (or src-sha1 (get-source-sha1 path))
                            (get-dep-sha1s deps up-to-date read-src-syntax mode #t))
                      deps)
               op)
        (newline op))))))

C:\Program Files\Racket\collects\racket\private\more-scheme.rkt: 158:2 
    (define (call-with-break-parameterization paramz thunk)
    (unless (break-paramz? paramz)
      (raise-type-error 'call-with-break-parameterization "break parameterization" 0 paramz thunk))
    (unless (and (procedure? thunk)
		 (procedure-arity-includes? thunk 0))
      (raise-type-error 'call-with-parameterization "procedure (arity 0)" 1 paramz thunk))
    (begin0
     (with-continuation-mark
	 break-enabled-key
	 (break-paramz-ref paramz 0)
       (begin
	 (check-for-break)
	 (thunk)))
     (check-for-break)))

C:\Program Files\Racket\collects\compiler\cm.rkt: 158:5 
       (lambda ()
       (begin0
         (let ([out (open-output-file tmp-path #:exists 'truncate/replace)])
           (dynamic-wind
            void
            (lambda ()
              (call-with-break-parameterization bp (lambda () (proc out tmp-path))))
            (lambda ()
              (close-output-port out))))
         (set! ok? #t)))

C:\Program Files\Racket\collects\racket\private\more-scheme.rkt: 158:2 
    (define (call-with-break-parameterization paramz thunk)
    (unless (break-paramz? paramz)
      (raise-type-error 'call-with-break-parameterization "break parameterization" 0 paramz thunk))
    (unless (and (procedure? thunk)
		 (procedure-arity-includes? thunk 0))
      (raise-type-error 'call-with-parameterization "procedure (arity 0)" 1 paramz thunk))
    (begin0
     (with-continuation-mark
	 break-enabled-key
	 (break-paramz-ref paramz 0)
       (begin
	 (check-for-break)
	 (thunk)))
     (check-for-break)))

C:\Program Files\Racket\collects\compiler\cm.rkt: 158:5 
       (lambda ()
       (begin0
         (let ([out (open-output-file tmp-path #:exists 'truncate/replace)])
           (dynamic-wind
            void
            (lambda ()
              (call-with-break-parameterization bp (lambda () (proc out tmp-path))))
            (lambda ()
              (close-output-port out))))
         (set! ok? #t)))

C:\Program Files\Racket\collects\compiler\cm.rkt: 389:42 
                     ((if sha1-only? values (lambda (build) (build) #f))

C:\Program Files\Racket\collects\compiler\cm.rkt: 354:0 
  (define (maybe-compile-zo sha1-only? deps mode path orig-path read-src-syntax up-to-date)
  (let ([actual-path (actual-source-path orig-path)])
    (unless sha1-only?
      ((manager-compile-notify-handler) actual-path)
      (trace-printf "compiling: ~a" actual-path))
    (begin0
     (parameterize ([indent (string-append "  " (indent))])
       (let* ([zo-name (path-add-suffix (get-compilation-path mode path) #".zo")]
              [zo-exists? (file-exists? zo-name)])
         (if (and zo-exists? (trust-existing-zos))
             (begin
               (log-info (format "cm: ~atrusting ~a" 
                                 (build-string 
                                  (depth)
                                  (? (x) (if (= 2 (modulo x 3)) #\| #\space)))
                                 zo-name))
               (touch zo-name)
               #f)
             (let ([src-sha1 (and zo-exists?
                                  deps
                                  (cadr deps)
                                  (get-source-sha1 path))])
               (if (and zo-exists?
                        src-sha1
                        (equal? src-sha1 (caadr deps))
                        (equal? (get-dep-sha1s (cddr deps) up-to-date read-src-syntax mode #f)
                                (cdadr deps)))
                   (begin
                     (log-info (format "cm: ~ahash-equivalent ~a" 
                                       (build-string 
                                        (depth)
                                        (? (x) (if (= 2 (modulo x 3)) #\| #\space)))
                                       zo-name))
                     (touch zo-name)
                     #f)
                   ((if sha1-only? values (lambda (build) (build) #f))
                    (lambda ()
                      (when zo-exists? (try-delete-file zo-name #f))
                      (log-info (format "cm: ~acompiling ~a" 
                                        (build-string 
                                         (depth)
                                         (? (x) (if (= 2 (modulo x 3)) #\| #\space)))
                                        actual-path))
                      (parameterize ([depth (+ (depth) 1)])
                        (with-handlers
                            ([exn:get-module-code?
                              (lambda (ex)
                                (compilation-failure mode path zo-name
                                                     (exn:get-module-code-path ex)
                                                     (exn-message ex))
                                (raise ex))])
                          (compile-zo* mode path src-sha1 read-src-syntax zo-name up-to-date))))))))))
     (unless sha1-only?
       (trace-printf "end compile: ~a" actual-path)))))

C:\Program Files\Racket\collects\compiler\cm.rkt: 448:2 
    (define (do-check)
    (let* ([main-path orig-path]
           [alt-path (rkt->ss orig-path)]
           [main-path-time (try-file-time main-path)]
           [alt-path-time (and (not main-path-time)
                               (not (eq? alt-path main-path))
                               (try-file-time alt-path))]
           [path (if alt-path-time alt-path main-path)]
           [path-time (or main-path-time alt-path-time)]
           [path-zo-time (get-compiled-time mode path)])
      (cond
       [(not path-time)
        (trace-printf "~a does not exist" orig-path)
        (or (and up-to-date (hash-ref up-to-date orig-path #f))
            (let ([stamp (cons path-zo-time
                               (delay (get-compiled-sha1 mode path)))])
              (hash-set! up-to-date main-path stamp)
              (unless (eq? main-path alt-path)
                (hash-set! up-to-date alt-path stamp))
              stamp))]
       [else
        (let ([deps (read-deps path)])
          (define build
            (cond
             [(not (and (pair? deps) (equal? (version) (car deps))))
              (lambda ()
                (trace-printf "newer version...")
                (maybe-compile-zo #f #f mode path orig-path read-src-syntax up-to-date))]
             [(> path-time path-zo-time)
              (trace-printf "newer src...")
              ;; If `sha1-only?', then `maybe-compile-zo' returns a #f or thunk:
              (maybe-compile-zo sha1-only? deps mode path orig-path read-src-syntax up-to-date)]
             [(ormap
               (lambda (p)
                 ;; (cons 'ext rel-path) => a non-module file (check date)
                 ;; rel-path => a module file name (check transitive dates)
                 (define ext? (and (pair? p) (eq? 'ext (car p))))
                 (define d (main-collects-relative->path (if ext? (cdr p) p)))
                 (define t
                   (if ext?
                       (cons (try-file-time d) #f)
                       (compile-root mode d up-to-date read-src-syntax #f)))
                 (and (car t)
                      (> (car t) path-zo-time)
                      (begin (trace-printf "newer: ~a (~a > ~a)..."
                                           d (car t) path-zo-time)
                             #t)))
               (cddr deps))
              ;; If `sha1-only?', then `maybe-compile-zo' returns a #f or thunk:
              (maybe-compile-zo sha1-only? deps mode path orig-path read-src-syntax up-to-date)]
             [else #f]))
          (cond
           [(and build sha1-only?) #f]
           [else
            (when build (build))
            (let ([stamp (cons (get-compiled-time mode path)
                               (delay (get-compiled-sha1 mode path)))])
              (hash-set! up-to-date main-path stamp)
              (unless (eq? main-path alt-path)
                (hash-set! up-to-date alt-path stamp))
              stamp)]))])))

C:\Program Files\Racket\collects\compiler\cm.rkt: 542:4 
      (define (compilation-manager-load-handler path mod-name)
      (cond [(not mod-name)
             (trace-printf "skipping:  ~a mod-name ~s" path mod-name)]
            [(not (or (file-exists? path)
                      (let ([p2 (rkt->ss path)])
                        (and (not (eq? path p2))
                             (file-exists? p2)))))
             (trace-printf "skipping:  ~a file does not exist" path)]
            [(or (null? (use-compiled-file-paths))
                 (not (equal? (car modes)
                              (car (use-compiled-file-paths)))))
             (trace-printf "skipping:  ~a compiled-paths's first element changed; current value ~s, first element was ~s"
                           path 
                           (use-compiled-file-paths)
                           (car modes))]
            [(not (eq? compilation-manager-load-handler
                       (current-load/use-compiled)))
             (trace-printf "skipping:  ~a current-load/use-compiled changed ~s"
                           path (current-load/use-compiled))]
            [(not (eq? orig-eval (current-eval)))
             (trace-printf "skipping:  ~a orig-eval ~s current-eval ~s"
                           path orig-eval (current-eval))]
            [(not (eq? orig-load (current-load)))
             (trace-printf "skipping:  ~a orig-load ~s current-load ~s"
                           path orig-load (current-load))]
            [(not (eq? orig-registry
                       (namespace-module-registry (current-namespace))))
             (trace-printf "skipping:  ~a orig-registry ~s current-registry ~s"
                           path orig-registry
                           (namespace-module-registry (current-namespace)))]
            [else
             (trace-printf "processing: ~a" path)
             (compile-root (car modes) path cache read-syntax #f)
             (trace-printf "done: ~a" path)])
      (default-handler path mod-name))


Posted on the dev mailing list.