digitalmars.D.learn - Strange 'memset' error when using std.range.repeat and std.array.array
- Ur nuz (48/48) Jan 04 2016 Need some help)...
- Ur nuz (5/5) Jan 04 2016 Sorry, the actual code is:
- tcak (2/7) Jan 04 2016 What's your OS? On Linux x64, it works without any error.
- Ur nuz (6/15) Jan 04 2016 Yes. It's Ubuntu 14. It works when it's in the separate example,
- Marc =?UTF-8?B?U2Now7x0eg==?= (5/22) Jan 04 2016 What is the value of `newIndentCount` when this happens? Could it
- Ur nuz (3/17) Jan 04 2016 The issue was trivial. I decreased variable with 0 value and got
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] 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__T6RepeatTaZ6R peatZ4TakeZ.array() at array.d:119 0x4bc699 std.array.__T5arrayTS3std5range43__T4TakeTS3std5range13__T6RepeatTaZ6R peatZ4TakeZ.array() at array.d:119 0x4bc5fb declarative.parser.__T6ParserTS11declarative11lexer_tools76__T16TextForwardRangeTAyaVS11declarative6common14LocationConfigS5i1i1i1i1i1Z16TextForwardRangeZ.Parser.p rseMixedBlockData() at parser.d:437 0x4c26e3 declarative.parser.__T6ParserTS11declarative11lexer_tools76__T16TextForwardRangeTAyaVS11declarative6common14LocationConfigS5i1i1i1i1i1Z16TextForwardRangeZ.Pars r.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?))
Jan 04 2016
Sorry, the actual code is: ... lines ~= ' '.repeat.take(newIndentCount).array; ...with character quotes. But it still fails with error described in stack trace in Gcx.bigAlloc()
Jan 04 2016
On Monday, 4 January 2016 at 10:50:17 UTC, Ur nuz wrote:Sorry, the actual code is: ... lines ~= ' '.repeat.take(newIndentCount).array; ...with character quotes. But it still fails with error described in stack trace in Gcx.bigAlloc()What's your OS? On Linux x64, it works without any error.
Jan 04 2016
On Monday, 4 January 2016 at 12:00:32 UTC, tcak wrote:On Monday, 4 January 2016 at 10:50:17 UTC, Ur nuz wrote:Yes. It's Ubuntu 14. It works when it's in the separate example, but not working inside my project. The strange thing is that it working in another place inside the same application. So I don't know what to think about it. Maybe this problem occurs only when some amount of memori is being allocated or something..Sorry, the actual code is: ... lines ~= ' '.repeat.take(newIndentCount).array; ...with character quotes. But it still fails with error described in stack trace in Gcx.bigAlloc()What's your OS? On Linux x64, it works without any error.
Jan 04 2016
On Monday, 4 January 2016 at 12:20:09 UTC, Ur nuz wrote:On Monday, 4 January 2016 at 12:00:32 UTC, tcak wrote:What is the value of `newIndentCount` when this happens? Could it be it is too big, or negative? If not, you could try reducing your program using dustmite: https://github.com/CyberShadow/DustMite/wiki/Detecting-a-specific-segfaultOn Monday, 4 January 2016 at 10:50:17 UTC, Ur nuz wrote:Yes. It's Ubuntu 14. It works when it's in the separate example, but not working inside my project. The strange thing is that it working in another place inside the same application. So I don't know what to think about it. Maybe this problem occurs only when some amount of memori is being allocated or something..Sorry, the actual code is: ... lines ~= ' '.repeat.take(newIndentCount).array; ...with character quotes. But it still fails with error described in stack trace in Gcx.bigAlloc()What's your OS? On Linux x64, it works without any error.
Jan 04 2016
On Monday, 4 January 2016 at 14:25:30 UTC, Marc Schütz wrote:On Monday, 4 January 2016 at 12:20:09 UTC, Ur nuz wrote:The issue was trivial. I decreased variable with 0 value and got OutOfMemory error.On Monday, 4 January 2016 at 12:00:32 UTC, tcak wrote:What is the value of `newIndentCount` when this happens? Could it be it is too big, or negative? If not, you could try reducing your program using dustmite: https://github.com/CyberShadow/DustMite/wiki/Detecting-a-specific-segfault[...]Yes. It's Ubuntu 14. It works when it's in the separate example, but not working inside my project. The strange thing is that it working in another place inside the same application. So I don't know what to think about it. Maybe this problem occurs only when some amount of memori is being allocated or something..
Jan 04 2016