digitalmars.D.learn - Array appending segfaults
- Artur Skawina (36/72) Oct 29 2011 Tried D today for the very first time, and the first program started seg...
- Jesse Phillips (2/4) Oct 29 2011 Not of much help, but I'm no reproducing it with DMD 2.056 Debian amd64.
Tried D today for the very first time, and the first program started segfaulting soon enough... The simplified version is this: ----- import core.thread; import std.stdio; class MyThread : Thread { this() { super(&run); } private: string s = "abcdefg"; void run() { writef("New thread starting.\n"); while (s.length < 300_000_000) s ~= s[0..4]; writef("New thread done.\n"); } } void main() { for( int n=0 ; n<8 ; n++ ) { Thread t = new MyThread(); t.start(); } writef("Main thread done.\n"); } ----- which often (>50%) results in:New thread starting. Main thread done. New thread starting. New thread starting. New thread starting. New thread starting. New thread starting. New thread starting. New thread starting. Segmentation fault (core dumped)Program terminated with signal 11, Segmentation fault. at ../../../libphobos/rt/lifetime.d:1739 1739 if(*(cast(size_t*)info.base) == size + offset) (gdb) bt full at ../../../libphobos/rt/lifetime.d:1739 newdata = <optimized out> newcap = 78018 newsize = 48159 length = <optimized out> info = {base = 0x0, size = 49152, attr = 10} sizeelem = 1 offset = <optimized out> size = 48155 newlength = 48159 bic = <optimized out> isshared = false at ../../../libphobos/rt/lifetime.d:1578 sizeelem = <optimized out> length = 48155 bugstrthsegf.d:17 No locals. ../../../libphobos/core/thread.d:1405 No locals.So it dies while trying to access info.base which is null. Nothing short of adding explicit locking around the append op seems to help... gcc version 4.6.2 20111024 (prerelease gdc 0.30, using dmd 2.055) (GCC) Target: x86_64-unknown-linux-gnu artur
Oct 29 2011
On Sat, 29 Oct 2011 18:37:18 +0200, Artur Skawina wrote:Tried D today for the very first time, and the first program started segfaulting soon enough... The simplified version is this:Not of much help, but I'm no reproducing it with DMD 2.056 Debian amd64.
Oct 29 2011