- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Lift compiles on Scala 2.8 and runs the demo
Fri, 2009-11-20, 01:31
Folks,
The 280_port of Lift properly compiles and runs the Lift demo application against the Scala 2.8.0 nightly.
I spent most of today tracking down a bug that I can't reproduce in isolation, but it seems that the ensureCapacity method in Scala's StringBuilder method has an infinite:
def ensureCapacity(n: Int) { 117 if (n > array.length) { 118 var newsize = array.length * 2 119 while (n > newsize) 120 newsize = newsize * 2 121 val newar = new Array[Char](newsize) 122 arraycopy(array, 0, newar, 0, count) 123 array = newar 124 } 125 }
I saw an infinite loop in lines 119/120 (it was line 115 in the version I was testing against). I replaced Scala's StringBuilder with the Java native code and all worked just fine. It might be worth a gander at the byte-code for StringBuilder to see how an infinite loop could happen.
Anyway, I'm looking forward to the next drop of a stable 2.8.0 so I can compile against Specs and get a more complete (read: passes tests... right now the tests are commented out because I don't have the Specs/ScalaCheck/etc. chain in the 2.8.0 nightly).
Thanks,
David
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics
The 280_port of Lift properly compiles and runs the Lift demo application against the Scala 2.8.0 nightly.
I spent most of today tracking down a bug that I can't reproduce in isolation, but it seems that the ensureCapacity method in Scala's StringBuilder method has an infinite:
def ensureCapacity(n: Int) { 117 if (n > array.length) { 118 var newsize = array.length * 2 119 while (n > newsize) 120 newsize = newsize * 2 121 val newar = new Array[Char](newsize) 122 arraycopy(array, 0, newar, 0, count) 123 array = newar 124 } 125 }
I saw an infinite loop in lines 119/120 (it was line 115 in the version I was testing against). I replaced Scala's StringBuilder with the Java native code and all worked just fine. It might be worth a gander at the byte-code for StringBuilder to see how an infinite loop could happen.
Anyway, I'm looking forward to the next drop of a stable 2.8.0 so I can compile against Specs and get a more complete (read: passes tests... right now the tests are commented out because I don't have the Specs/ScalaCheck/etc. chain in the 2.8.0 nightly).
Thanks,
David
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics
Fri, 2009-11-20, 01:57
#2
Re: Lift compiles on Scala 2.8 and runs the demo
On Thu, Nov 19, 2009 at 4:44 PM, Paul Phillips <paulp@improving.org> wrote:
On Thu, Nov 19, 2009 at 04:31:39PM -0800, David Pollak wrote:
> I spent most of today tracking down a bug that I can't reproduce in
> isolation, but it seems that the ensureCapacity method in Scala's
> StringBuilder method has an infinite:
Yeah, it was pretty obvious knowing it was there. This will show it:
new StringBuilder(0, "").ensureCapacity(1)
Because:
while (n > newsize)
newsize = newsize * 2
And um 0 * 2 == 0
Nice
--
Paul Phillips | Simplicity and elegance are unpopular because
Stickler | they require hard work and discipline to achieve
Empiricist | and education to be appreciated.
i pull his palp! | -- Dijkstra
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics
Fri, 2009-11-20, 07:27
#3
Re: Lift compiles on Scala 2.8 and runs the demo
On Thu, 2009-11-19 at 16:44 -0800, Paul Phillips wrote:
> On Thu, Nov 19, 2009 at 04:31:39PM -0800, David Pollak wrote:
> > I spent most of today tracking down a bug that I can't reproduce in
> > isolation, but it seems that the ensureCapacity method in Scala's
> > StringBuilder method has an infinite:
>
> Yeah, it was pretty obvious knowing it was there. This will show it:
>
> new StringBuilder(0, "").ensureCapacity(1)
>
> Because:
>
> while (n > newsize)
> newsize = newsize * 2
>
> And um 0 * 2 == 0
I was looking at the fix[1] and it doesn't seem to me like it's the
correct fix (although it does fix the infinite loop). If I call
ensureCapacity and the internal array length is 0, I still want the
method to do what I asked, right?
Best,
Ismael
Fri, 2009-11-20, 08:37
#4
Re: Lift compiles on Scala 2.8 and runs the demo
On Fri, Nov 20, 2009 at 06:21:09AM +0000, Ismael Juma wrote:
> I was looking at the fix[1] and it doesn't seem to me like it's the
> correct fix (although it does fix the infinite loop). If I call
> ensureCapacity and the internal array length is 0, I still want the
> method to do what I asked, right?
It was a race against time over here, every second counts when you are
trying to head off a bug which leaks INFINITY CYCLES. Oh sure, you
monday morning quarterbacks can make your air quotes around
"correctness" but statistically speaking my decisive action must have
saved some very small but finite positive number of people from hitting
that loop, and that number * infinity == infinity, so therefore not only
was it the right thing to do, it was INFINITELY RIGHT.
And now that I have infinite karma you better watch out because I no
longer need abide by society's constraints.
Fri, 2009-11-20, 15:27
#5
Re: Lift compiles on Scala 2.8 and runs the demo
It's the aptness of the quote in that signature which gets me :)
On Fri, Nov 20, 2009 at 7:35 AM, Paul Phillips <paulp@improving.org> wrote:
On Fri, Nov 20, 2009 at 7:35 AM, Paul Phillips <paulp@improving.org> wrote:
On Fri, Nov 20, 2009 at 06:21:09AM +0000, Ismael Juma wrote:
> I was looking at the fix[1] and it doesn't seem to me like it's the
> correct fix (although it does fix the infinite loop). If I call
> ensureCapacity and the internal array length is 0, I still want the
> method to do what I asked, right?
It was a race against time over here, every second counts when you are
trying to head off a bug which leaks INFINITY CYCLES. Oh sure, you
monday morning quarterbacks can make your air quotes around
"correctness" but statistically speaking my decisive action must have
saved some very small but finite positive number of people from hitting
that loop, and that number * infinity == infinity, so therefore not only
was it the right thing to do, it was INFINITELY RIGHT.
And now that I have infinite karma you better watch out because I no
longer need abide by society's constraints.
--
Paul Phillips | Every normal man must be tempted at times
Everyman | to spit on his hands, hoist the black flag,
Empiricist | and begin to slit throats.
pp: i haul pills | -- H. L. Mencken
On Thu, Nov 19, 2009 at 04:31:39PM -0800, David Pollak wrote:
> I spent most of today tracking down a bug that I can't reproduce in
> isolation, but it seems that the ensureCapacity method in Scala's
> StringBuilder method has an infinite:
Yeah, it was pretty obvious knowing it was there. This will show it:
new StringBuilder(0, "").ensureCapacity(1)
Because:
while (n > newsize)
newsize = newsize * 2
And um 0 * 2 == 0