seanjensengrey / mosh-scheme

Automatically exported from code.google.com/p/mosh-scheme
Other
0 stars 0 forks source link

weird error related to bytevector-u32 while compiling library #72

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile the library at:

http://github.com/marcomaggi/nausicaa/blob/ad81d44cf7a59daa118c928b7a7e546b4480c
eaa/scheme/src/libraries/random.sls

What is the expected output? What do you see instead?
It should work with no errors (it does with Ikarus, Larceny and Ypsilon). I
see the following error:

CALL: stack expansion
CALL: stack expansion
CALL: stack expansion
*** testing random
 Condition components:
 1. &assertion
 2. &who             who: "bytevector-s32-native-set!"
 3. &message         message: "fixnum required, but got 4006044394"
 4. &irritants       irritants: ()

 Exception:
     error in raise: returned from non-continuable exception

 Stack trace:
    1. throw: <subr>
    2. (raise c):  compiler-with-library.scm:889
    3. bytevector-u32-native-set!: <subr>
    4. (lambda G1235 G1237): <unknown location>
    5. apply: <subr>

The who of the error mentions bytevector-s32-native-set!, but the error is
raised by bytevector-u32-native-set! (my code never calls the s32 version).
It is not clear if the problem is about an index out of range or a s32/u32
out of range, but the number 4006044394 is a valid u32. The library should
not evaluate any bytevector---- call at compilation time, all of them have
both the arguments dependent upon runtime values. Of course all the
pseudo-random generators have deterministic output and the library preseeds
them, so Mosh may figure out that a lot can be precomputed, is this what
happens? The program file that imports the library is:

http://github.com/marcomaggi/nausicaa/blob/ad81d44cf7a59daa118c928b7a7e546b4480c
eaa/scheme/tests/test-random.sps

What version of the product are you using? On what operating system?
Mosh checkout 1877. i686-pc-linux-gnu.

Original issue reported on code.google.com by mrc....@gmail.com on 2 Jul 2009 at 11:45

GoogleCodeExporter commented 9 years ago
I get it with Mosh revision 1892, too.

Original comment by mrc....@gmail.com on 2 Jul 2009 at 1:47

GoogleCodeExporter commented 9 years ago
Thanks.
I have succeed in reproducing the problem.

Original comment by hige...@gmail.com on 2 Jul 2009 at 2:01

GoogleCodeExporter commented 9 years ago
Fixed it was a bug of bytevector-u32-native-set!.
r1894.

(1) How to reproduce

(import (nausicaa)
  (checks)
  (random))
(parameterise ((check-test-name 'default-source))
  (let* ((bytevector-maker (random-source-bytevectors-maker default-random-source))
         (obj (bytevector-maker 50)))
    (check-for-true (bytevector? obj))))

(check-report)

(2) As you pointed out error message was wrong.
   bytevector-s32-native-set! => bytevector-u32-native-set!

(3) And we should have accepted Bignum also. (Fixnum is smaller than U32_MAX).

BTW, I have runned your (nausicaa) libraries, Mosh is very slow on compilation.
As you suggested, I will do two things for better performance.

(a) speed up of compilation

(b) auto pre-compilation on first time run.

Cheers.

Original comment by hige...@gmail.com on 2 Jul 2009 at 2:55