Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion failure with partcont #244

Closed
leque opened this issue Oct 17, 2016 · 1 comment
Closed

Assertion failure with partcont #244

leque opened this issue Oct 17, 2016 · 1 comment

Comments

@leque
Copy link
Contributor

leque commented Oct 17, 2016

% gosh -V
Gauche scheme shell, version 0.9.5 [utf-8,pthreads], x86_64-apple-darwin16.0.0

Running a following program causes an assertion failure.

% cat cont.scm
(use gauche.partcont)

(define (f args)
  (reset
    (let ((in (shift k
                (call-with-input-file (cadr args) k))))
      (write (read-char in))
      (newline)
      0)))

;; OK
(f (command-line))
;; -| #<eof>

(define (main args)
  (f args))
;; -| #<eof>
;; --> "./vminsn.scm", line 1370: Assertion failed: SCM_PAIRP((vm)->handlers)

It seems OK to call f, a function using shift/reset, at the top-level, but causes an assertion failure to call it from main.

% gosh cont.scm /dev/null
#<eof>
#<eof>
"./vminsn.scm", line 1370: Assertion failed: SCM_PAIRP((vm)->handlers)
VM 0x101182c80 -----------------------------------------------------------
   pc: 0x100276da8 (0000000e)
   sp: 0x101184020  base: 0x101184000  [0x101184000-0x101197880]
 argp: 0x101184020
 val0: 0
 envs:
   0x101184008 #f
       up=0x1013da2e0 size=1
       [ (0) ]
   0x1013da2e0 #f
       up=0x1013dfae8 size=2
       [ #<closure ((call-with-input-file #f #f) . #f)> #<closure ((call-with-input-file #f #f) . #f)> ]
   0x1013dfae8 #f
       up=0x1013dfac8 size=1
       [ #<closure ((#f #:G1331) code fmt args)> ]
   0x1013dfac8 #f
       up=0x1013da378 size=1
       [ #<iport /dev/null 0x1011ddc00> ]
   0x1013da378 (call-with-input-file filename proc . flags)
       up=0x0 size=3
       [ () #<closure ((call/pc #f #f) . args)> "/dev/null" ]
conts:
   0x1013dc010
              env = 0x1001c0628
             size = 2
               pc = {cproc 0x100020870}
             base = 0x100272df0
   0x1013da420
              env = 0x0
             size = 0
               pc = 0x1002c7590 (00000000)
             base = 0x1013d6c60
   0x1013da3f0
              env = 0x0
             size = 0
               pc = 0x1002c7590 (00000000)
             base = 0x0
C stacks:
  0x7fff5fbfeee0: prev=0x7fff5fbff130, cont=0x1013da420
  0x7fff5fbff130: prev=0x0, cont=0x1013da3f0
Escape points:
dynenv: ()
Code:
=== main_code (name=#f, code=0x100276d08, size=48, const=0 stack=16):
signatureInfo: ()
     0 CLOSURE #<lambda 0>
     2 PUSH 
     3 CLOSURE #<lambda 1>
     5 PUSH-LOCAL-ENV(2) 
     6 PRE-CALL(0) 10
     8 LREF0 
     9 LOCAL-ENV-CALL(0) 
    10 LREF0-PUSH 
    11 LREF1 
    12 PUSH-HANDLERS 
    13 PRE-CALL(1) 18
    15 LREF20-PUSH 
    16 LREF(3,1) 
    17 CALL(1) 
    18 TAIL-RECEIVE(0,1) 
    19 POP-HANDLERS 
    20 PRE-CALL(0) 24
    22 LREF11 
    23 LOCAL-ENV-CALL(0) 
    24 PRE-CALL(0) 30
    26 GREF-PUSH #<gloc scheme#values inlinable>
    28 LREF0 
    29 TAIL-APPLY(2) 
    30 POP-LOCAL-ENV 
    31 POP-LOCAL-ENV 
    32 TAIL-RECEIVE(0,1) 
    33 LREF20 
    34 BF 43
    36 PRE-CALL(1) 43
    38 LREF20-PUSH 
    39 GREF-CALL(1) #<gloc scheme#close-input-port>
    41 JUMP 43
    43 GREF-PUSH #<gloc scheme#values inlinable>
    45 LREF0 
    46 TAIL-APPLY(2) 
    47 RET 
=== closure:1 (name=#f, code=0x100276ce0, size=5, const=0 stack=4):
signatureInfo: ()
     0 CLOSURE #<lambda 2>
     2 PUSH-GREF-TAIL-CALL(1) #<gloc gauche#exit-handler>
     4 RET 
=== closure:2 (name=#f, code=0x100276c60, size=16, const=0 stack=10):
signatureInfo: (code fmt args)
     0 LREF20 
     1 BF 10
     3 PRE-CALL(1) 10
     5 LREF20-PUSH 
     6 GREF-CALL(1) #<identifier gauche.internal#close-input-port.1221660>
     8 JUMP 10
    10 LREF2-PUSH 
    11 LREF1-PUSH 
    12 LREF0-PUSH 
    13 LREF10 
    14 TAIL-CALL(3) 
    15 RET 
=== closure:0 (name=#f, code=0x100276c40, size=4, const=0 stack=4):
signatureInfo: ()
     0 LREF0-PUSH 
     1 GREF-TAIL-CALL(1) #<gloc gauche#exit-handler>
     3 RET 
exitting...
shirok added a commit that referenced this issue Oct 17, 2016
@shirok
Copy link
Owner

shirok commented Oct 17, 2016

Fixed by 97196ad

@shirok shirok closed this as completed Oct 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants