Thread overview
[Issue 8551] New: Endless Split
Aug 15, 2012
Daniel Cousens
Aug 16, 2012
Daniel Cousens
Aug 16, 2012
Daniel Cousens
Aug 16, 2012
Daniel Cousens
Aug 16, 2012
Daniel Cousens
August 15, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8551

           Summary: Endless Split
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: daniel350@bigpond.com


--- Comment #0 from Daniel Cousens <daniel350@bigpond.com> 2012-08-15 06:59:47 PDT ---
import std.array;

void main() {
      auto s = "abc";
      auto r = s.split("");

      assert(false); // won't ever be reached
}


The assert is never reached, for whatever reason, the compiler hangs (possible in an infinite loop somewhere).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 16, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8551



--- Comment #1 from Daniel Cousens <daniel350@bigpond.com> 2012-08-16 02:25:07 PDT ---
Warning, this will cause a memory explosion and you *will* eventually get an OutOfMemoryException.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 16, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8551



--- Comment #2 from Daniel Cousens <daniel350@bigpond.com> 2012-08-16 04:27:24 PDT ---
import std.algorithm;
import std.stdio;

void main() {
      auto s = "abc";
      writeln(s.find("").length); // prints 3 - what the?
      writeln(s.find(",").length); // prints 0 - expected
      writeln(s.find("b").length); // prints 2 - expected
}

The problem is from the second implementation of the `splitter` in
std/algorithm.d (:2118). Possibly rooted in erroneous output from find (see
above).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 16, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8551



--- Comment #3 from Daniel Cousens <daniel350@bigpond.com> 2012-08-16 05:58:36 PDT ---
(In reply to comment #2)
> import std.algorithm;
> import std.stdio;
> 
> void main() {
>       auto s = "abc";
>       writeln(s.find("").length); // prints 3 - what the?
>       writeln(s.find(",").length); // prints 0 - expected
>       writeln(s.find("b").length); // prints 2 - expected
> }
> 
> The problem is from the second implementation of the `splitter` in
> std/algorithm.d (:2118). Possibly rooted in erroneous output from find (see
> above).

As was explained to me by CyberShadow, it does not appear to be erroneous output from find; but most likely just an edge case in splitter.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 16, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8551



--- Comment #4 from Daniel Cousens <daniel350@bigpond.com> 2012-08-16 06:09:03 PDT ---
The culprit lies in the fact that when find() returns a string the same length as the input; _frontLength is then left as `0`.

This later leads to the following result in popFront():

_input = _input[_frontLength + separatorLength .. _input.length];

is equal to

_input = _input[0 .. _input.length];

Ie, unchanged.
Therefore, the range remains the same length, and never completes.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8551


monarchdodra@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |monarchdodra@gmail.com
         Resolution|                            |DUPLICATE


--- Comment #5 from monarchdodra@gmail.com 2012-10-22 02:42:41 PDT ---
*** This issue has been marked as a duplicate of issue 5977 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------