Skip to content

Trying to call String on a SubString{Base.AnnotatedString{String}} stack overflows unless StyledStrings is loaded #59578

@KristofferC

Description

@KristofferC

Repro:

❯ julia +1.12-nightly -e 'String(SubString(Base.AnnotatedString("foo")))'
Warning: detected a stack overflow; program state may be corrupted, so further execution might be unreliable.
ERROR: StackOverflowError:
Stacktrace:
     [1] _string_n
       @ ./strings/string.jl:109 [inlined]
     [2] StringMemory
       @ ./iobuffer.jl:167 [inlined]
     [3] #IOBuffer#390
       @ ./iobuffer.jl:266 [inlined]
     [4] GenericIOBuffer
       @ ./iobuffer.jl:245 [inlined]
     [5] print_to_string(xs::SubString{Base.AnnotatedString{String}})
       @ Base ./strings/io.jl:149
     [6] String
       @ ./strings/string.jl:117 [inlined]
     [7] ansi_write(f::typeof(write), io::IOBuffer, x::SubString{Base.AnnotatedString{String}})
       @ Base.AnnotatedDisplay ./strings/annotated_io.jl:214
     [8] ansi_write_
       @ ./strings/annotated_io.jl:216 [inlined]
     [9] print
       @ ./strings/annotated_io.jl:241 [inlined]
    [10] print_to_string(xs::SubString{Base.AnnotatedString{String}})
       @ Base ./strings/io.jl:151
--- the above 5 lines are repeated 18689 more times ---
 [93456] String(s::SubString{Base.AnnotatedString{String}})
       @ Base ./strings/string.jl:117

cc @tecosaur

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorstrings"Strings!"

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions