Strange 'memset' error when using std.range.repeat and std.array.array
via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jan 4 02:46:35 PST 2016
Need some help)...
Having the following chunk of code:
string[] lines;
...
if( firstIndentStyle == IndentStyle.space )
{
lines ~= " ".repeat.take(newIndentCount).array;
}
else //Tabs
{
lines ~= "\t".repeat.take(newIndentCount).array; //This causes
strange 'memset' error
}
This code fails with seg fault in memset. And I don't know why?
here goes stack trace:
declarative [20930] [cores: 3]
Thread #1 [declarative] 20930 [core: 3] (Suspended : Signal :
SIGSEGV:Segmentation fault)
gc.gc.Gcx.bigAlloc() at 0x4dbc73
gc.gc.GC.malloc() at 0x4d9375
gc_malloc() at 0x4cc308
core.memory.GC.malloc() at 0x4cbe64
std.array.__T14arrayAllocImplVbi0TAaTmZ.arrayAllocImpl() at
array.d:628 0x4a1185
std.array.__T18uninitializedArrayTAaTmZ.uninitializedArray() at
array.d:533 0x4a1155
std.array.__T5arrayTS3std5range43__T4TakeTS3std5range13__T6RepeatTaZ6RepeatZ4TakeZ.array() at array.d:119 0x4bc699
std.array.__T5arrayTS3std5range43__T4TakeTS3std5range13__T6RepeatTaZ6RepeatZ4TakeZ.array() at array.d:119 0x4bc5fb
declarative.parser.__T6ParserTS11declarative11lexer_tools76__T16TextForwardRangeTAyaVS11declarative6common14LocationConfigS5i1i1i1i1i1Z16TextForwardRangeZ.Parser.parseMixedBlockData() at parser.d:437 0x4c26e3
declarative.parser.__T6ParserTS11declarative11lexer_tools76__T16TextForwardRangeTAyaVS11declarative6common14LocationConfigS5i1i1i1i1i1Z16TextForwardRangeZ.Parser.parseMixedBlock() at parser.d:481 0x4c29fa
<...more frames...>
Tried to reduce example into the folowing (and it is working!):
module bug_test;
import std.stdio;
import std.range;
void main()
{
import std.array: array;
string[] lines;
size_t newIndentCount = 8;
lines ~= ' '.repeat.take(newIndentCount).array;
writeln( lines );
}
Could someone imagine why this could happen?))
More information about the Digitalmars-d-learn
mailing list