unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* Bug in make-shared-array.
@ 2006-02-27 16:16 Steve Juranich
  0 siblings, 0 replies; 12+ messages in thread
From: Steve Juranich @ 2006-02-27 16:16 UTC (permalink / raw)


I tried posting this on Friday, but it doesn't look like it went through. 
Here we go again...

I've found a bug in the guile 1.8.0 release such that one of the examples on
the info page about shared arrays doesn't work in guile.  The example in
question is:

(make-shared-array #1(a b c d e f g h i j k l)
                             (lambda (i j) (list (+ (* i 3) j)))
                             4 3)

The expected result is:  #2((a b c) (d e f) (g h i) (j k l)), which is what
I get for guile 1.6.7.  However, running the example in guile 1.8.0, I get
a backtrace.  Specifically:

guile> (make-shared-array #1(a b c d e f g h i j k l)
...                              (lambda (i j) (list (+ (* i 3) j)))
...                              4 3)

Backtrace:
In current input:
   1: 0* [make-shared-array #(a b c d e f g h i ...) #<procedure #f (i j)> 4
3]

<unnamed port>:1:1: In procedure make-shared-array in expression
(make-shared-array (quote #) (lambda # #) ...):
<unnamed port>:1:1: mapping out of range
ABORT: (misc-error)

I've done a little poking around and can isolate the problem to a call to
SCM_I_ARRAY_BASE at libguile/unif.c:912.

I'm working on this problem right now and hope to have a patch by the end of
the day, but any help would be greatly appreciated.

Thanks.
-- 
Steve Juranich
Tucson, AZ
USA



_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile


^ permalink raw reply	[flat|nested] 12+ messages in thread
* Bug in make-shared-array.
@ 2006-02-27 18:16 Steve Juranich
  0 siblings, 0 replies; 12+ messages in thread
From: Steve Juranich @ 2006-02-27 18:16 UTC (permalink / raw)


I tried posting this on Friday, but it doesn't look like it went through. 
Here we go again...

I've found a bug in the guile 1.8.0 release such that one of the examples on
the info page about shared arrays doesn't work in guile.  The example in
question is:

(make-shared-array #1(a b c d e f g h i j k l)
                             (lambda (i j) (list (+ (* i 3) j)))
                             4 3)

The expected result is:  #2((a b c) (d e f) (g h i) (j k l)), which is what
I get for guile 1.6.7.  However, running the example in guile 1.8.0, I get
a backtrace.  Specifically:

guile> (make-shared-array #1(a b c d e f g h i j k l)
...                              (lambda (i j) (list (+ (* i 3) j)))
...                              4 3)

Backtrace:
In current input:
   1: 0* [make-shared-array #(a b c d e f g h i ...) #<procedure #f (i j)> 4
3]

<unnamed port>:1:1: In procedure make-shared-array in expression
(make-shared-array (quote #) (lambda # #) ...):
<unnamed port>:1:1: mapping out of range
ABORT: (misc-error)

I've done a little poking around and can isolate the problem to a call to
SCM_I_ARRAY_BASE at libguile/unif.c:912.

When SCM_I_ARRAY_BASE gets called on a 1-d array, things seem to work okay,
but when SCM_I_ARRAY_BASE is called on a 2-d array things seem to go
sideways.

I'd like to be able to patch this myself, but I'm not sure how fast I'd be
able to come up to speed on how the API works to be able to do that.

Any help here would be very much appreciated.

Thanks.
-- 
Steve Juranich
Tucson, AZ
USA



_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile


^ permalink raw reply	[flat|nested] 12+ messages in thread
* Bug in make-shared-array.
@ 2006-02-27 23:12 Steve Juranich
  2006-03-03 23:52 ` Kevin Ryde
  0 siblings, 1 reply; 12+ messages in thread
From: Steve Juranich @ 2006-02-27 23:12 UTC (permalink / raw)


I've tried posting a couple of messages about this via gmane.org, but
they still haven't posted to the list, that I can see.  Sorry if
people are seeing multiple versions of this.

There is a bug in scm_make_shared_array that causes things to break
when the input array is 1-d.  I thought I had a working patch for
this, but I don't.  Anyway, the offending line is libguile/unif.c:912:

  SCM_I_ARRAY_BASE (ra) = new_min = new_max = i + SCM_I_ARRAY_BASE (oldra);

As far as I can tell, there is a bug somewhere in the SCM_I_ARRAY_BASE
macro that causes things to break when oldra is a 1d uniform array. 
The value of the array base seems to be sane for multi-dimensional
arrays, but is something very strange for 1d arrays.

Here's the proof:

<buggy.c>
#include <stdio.h>
#include <libguile.h>

SCM
show_base_wrap(SCM ra) {
  size_t base = SCM_I_ARRAY_BASE(ra);
  printf("base = %d.\n", base);
  return SCM_UNSPECIFIED;
}

void
init_buggy () {
  scm_c_define_gsubr("show-base", 1, 0, 0, show_base_wrap);
}
</buggy.c>

Then the scheme code that shows this off would be:
<proof.scm>
#! /bin/bash
exec guile -s "$0" "$@"
!#

(use-modules (ice-9 format))

(setenv "LD_LIBRARY_PATH" (string-append ".:" (getenv "LD_LIBRARY_PATH")))

(load-extension "buggy" "init_buggy")

(define good #2((a b c) (d e f) (g h i)))
(define bad  #1(a b c d e f g h i))

(format #t "This one should work:~%~!")
(show-base good)

(format #t "While this one should be weird.~%~!")
(show-base bad)
</proof.scm>

Are there any workarounds for this?

BTW:
GCC 3.4.4
libtool-1.5.2
SuSE 9.3 everything else.

Thanks a bunch.
--
Steve Juranich
Tucson, AZ
USA


_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-06-14  0:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-27 16:16 Bug in make-shared-array Steve Juranich
  -- strict thread matches above, loose matches on Subject: below --
2006-02-27 18:16 Steve Juranich
2006-02-27 23:12 Steve Juranich
2006-03-03 23:52 ` Kevin Ryde
2006-03-11  0:07   ` Neil Jerram
2006-05-01 21:48     ` Marius Vollmer
2006-05-01 22:13     ` Marius Vollmer
2006-05-01 23:07     ` Marius Vollmer
2006-05-03 23:29       ` Kevin Ryde
2006-05-04 17:55       ` Steve Juranich
2006-05-04 21:27         ` Marius Vollmer
2006-06-14  0:45       ` Neil Jerram

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).