Re: Likely Bug in JVM backend

[email protected]
Newsgroups gmane.lisp.scheme.bigloo
Organization Inria
Message-ID <[email protected]>
Hi Bernard,

Joseph recently sent this error report.

> When compiling the module below with either 4.3a or 4.3b for the JVM
> backend and running it, I seeing the following error:
> 
>     bigloo.bexception
>             at bigloo.foreign.jumpexit(foreign.java:4929)
>             at bigloo.runtime.Llib.bexit.unwind-stack-until!(bexit.scm)
>             at bigloo.runtime.Llib.bexit.unwind-until!(bexit.scm)
>             at vector-contains.&collection-contains?1025(vector-
>     contains.scm)
>             at vector-contains.funcall2(vector-contains.scm)
>             at vector-contains.collection-contains?(vector-contains.scm)
>             at vector-contains.main(vector-contains.scm)
>             at vector-contains.bigloo_main(vector-contains.scm)
>             at vector-contains.main(vector-contains.scm)
> 
> I don't see the error when compiling to native code or if I change the
> inline functions to regular functions.
> 
> It is not really a problem since I am able to easily code around it,
> but I thought you would appreciate hearing about it. 
> 
> 
> Thank You,
> Joseph Donaldson
> 
> ------ collection-contains.scm --------
> (module collection-contains
>        (main main))
> 
> 
> (define-inline (vector-contains? vec itm)
>    (bind-exit (found)
>       (do ((i 0 (+ i 1)))
>           ((= i (vector-length vec) (found #f)))
>           (when (equal? (vector-ref vec i) itm)
>              (found #t)))))
> 
> (define-inline (coll-string-contains? str itm)
>    (bind-exit (return)
>       (do ((i 0 (+ i 1)))
>           ((= i (string-length str) (return #f))
>            (when (equal? (string-ref str i) itm)
>               (return #t))))))
> 
> 
> (define-generic (collection-contains? obj itm)
>    (cond ((vector? obj)
>           (vector-contains? obj itm))
>          ((string? obj)
>           (coll-string-contains? obj itm))))
>    
> 
> (define (main args)
>    (print (collection-contains? '#(1 2 3) 4)))
I have simplified it a little bit for:

-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----
(module collection-contains
       (main main))


(define-inline (vector-contains? vec itm)
   (bind-exit (found)
      (do ((i 0 (+ i 1)))
          ((= i (vector-length vec) (found #f)))
          (when (equal? (vector-ref vec i) itm)
             (found #t)))))

(define-inline (coll-string-contains? str itm)
   (bind-exit (return)
      (return #f)))


(define (collection-contains? obj itm)
   (cond ((vector? obj)
          (vector-contains? obj itm))
         ((string? obj)
          (coll-string-contains? obj itm))))
   

(define (main args)
   (print ((car (list collection-contains?)) '#(1 2 3) 4)))
-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----

and the runtime error is more explicit, I think:

-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.VerifyError: (class: foo, method: BgL_z62collectionzd2containszf3z43 signature: (Lbigloo/procedure;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;) Stack size too large
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
	at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
	at java.lang.Class.getMethod0(Class.java:3018)
	at java.lang.Class.getMethod(Class.java:1784)
	at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
redrock:.../serrano/trashcan> bigloo foo.scm -jvm -v2 
-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----

If I reduce it even more:

-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----
(module collection-contains
       (main main))


(define-inline (vector-contains? vec itm)
   (bind-exit (found)
      (found #t)))

(define-inline (coll-string-contains? str itm)
   (bind-exit (return)
      (return #f)))


(define (collection-contains? obj itm)
   (cond ((vector? obj)
          (vector-contains? obj itm))
         ((string? obj)
          (coll-string-contains? obj itm))))
   

(define (main args)
   (print ((car (list collection-contains?)) '#(1 2 3) 4)))
-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----

The error is:

-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----
bigloo.bexception
	at bigloo.foreign.jumpexit(foreign.java:4929)
	at bigloo.runtime.Llib.bexit.unwind-stack-until!(bexit.scm)
	at bigloo.runtime.Llib.bexit.unwind-until!(bexit.scm)
	at foo.&collection-contains?(foo.scm)
	at foo.funcall2(foo.scm)
	at foo.main(foo.scm)
	at foo.bigloo_main(foo.scm)
	at foo.main(foo.scm)
-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----

Do you think you will have time to check what is going on? Is there anything
I could do to help?

Thanks in advance,

-- 
Manuel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.