racket / racket/web-server

Cryptic contract violation from with-current-saved-continuation-marks-and

Open
#69 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Racket
Stars
99
Forks
48
PR merge metrics
No merged PRs in 30d

Description

After refactoring a big web-server program, attempting to run it now blames one of my modules for violating the contract of with-current-saved-continuation-marks-and ("expected 1 value, returned 2 values in: the range of the 3rd argument of (-> any/c any/c (-> any/c) any/c)"—full message below).

I am not sure how to minimize this example. The blamed module doesn't use with-current-saved-continuation-marks-and directly (nor does any of my code), and it doesn't even seem to use or define any functions with multiple return values. It is written in a language based on #lang web-server. (Changing to the plain #lang web-server doesn't seem to help.)

The bug seems to be the web server's fault: changing the blamed module to use #lang racket/base seems to fix the error. (It isn't clear why this module was in a web-server-based language in the first place: my guess is that I left it that way in an earlier refactoring.)

The contract problem happens both in Racket 7.4 CS and in traditional Racket built from master, but Racket CS has an additional problem: if I try to run the blamed module directly (i.e. racket portal/private-servlet/feedback/notify.rkt) when it's #lang is either web-server or my web-server-based language, Racket 7.4 CS has an "invalid memory reference," whereas traditional Racket succeeds.

Here's the full error message:

Sapientia:ricoeur-portal philip$ ./config/no-voyant-test.rkt 
with-current-saved-continuation-marks-and: contract violation;
 expected 1 value, returned 2 values
  in: the range of
      the 3rd argument of
      (-> any/c any/c (-> any/c) any/c)
  contract from: 
      <pkgs>/web-server-lib/web-server/lang/abort-resume.rkt
  blaming: <pkgs>/ricoeur-portal/portal/private-servlet/feedback/notify.rkt
   (assuming the contract is correct)
  at: <pkgs>/web-server-lib/web-server/lang/abort-resume.rkt:244.2
  context...:
   /Users/pltbuild/build/plt-release-64/bundle/racket/collects/racket/contract/private/blame.rkt:347:0: raise-blame-error16
   loop
   /Users/pltbuild/build/plt-release-64/bundle/racket/collects/racket/contract/private/arrow-common.rkt:63:5
   call-with-values
   call-with-values
   call-with-values
   /Users/philip/code/ricoeur/ricoeur-portal/config.rkt:207:22: pr:proc
   call-with-values
   /Users/pltbuild/build/plt-release-64/bundle/racket/collects/racket/private/promise.rkt:103:0: force/generic
   /Users/philip/code/ricoeur/ricoeur-portal/config.rkt:217:21
   call-with-values
   body of (submod "/Users/philip/code/ricoeur/ricoeur-portal/config/no-voyant-test.rkt" main)
   temp37_0
   for-loop
   run-module-instance!125
   #%for-each

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with web-server/lang/abort-resume.rkt around line 244 and the blamed portal/private-servlet/feedback/notify.rkt module, then inspect the stack references in config.rkt. Reproduce the contract violation with the web-server-based language and compare direct execution under web-server and racket/base; done means the reported failure and CS invalid-memory-reference behavior are explained and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Domain
backend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.