D - Bug in Outbuffer?
- Friedrich Dominicus (39/39) Aug 20 2003 I copied the code from outbuffer.d to a new file. It looks like this:
- Walter (2/2) Aug 21 2003 Try deleting lines of code from it until the problem goes away, that way...
- Friedrich Dominicus (32/36) Aug 24 2003 The bugs seems to be with printf:
I copied the code from outbuffer.d to a new file. It looks like this: import outbuffer; int main(){ OutBuffer buf = new OutBuffer(); //printf("buf = %p\n", buf); //printf("buf.offset = %x\n", buf.offset); assert(buf.offset == 0); buf.write("hello"); buf.write(cast(byte)0x20); buf.write("world"); buf.printf(" %d", 6); // printf("buf = '%.*s'\n", buf.toString()); return 0; } If I run this code I code crash with this backtrace: (gdb) run Starting program: /home/frido/Arbeit/LM/D/src/bug_1 (no debugging symbols found)...[New Thread 16384 (LWP 5652)] (no debugging symbols found)... (no debugging symbols found)...(no debugging symbols found)... Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 16384 (LWP 5652)] 0x08049c3b in _D9outbuffer9OutBuffer6spreadFkkZv () (gdb) backtrace I do not think that this should happen. I'm running DMD 0.69 on a Debian/unstable box Libc version 2.3.x Another point. I wrote about a generic way for printing objects. Now it seems Outbuffer is the answer, unfortunatly there's not function for printing an Object. I wonder if this patch would work: void write(Object o){ reserve(o.toString().size); write(o.toString()); } Regards Friedrich
Aug 20 2003
Try deleting lines of code from it until the problem goes away, that way at least it's down to which line is the problem.
Aug 21 2003
Walter wrote:Try deleting lines of code from it until the problem goes away, that way at least it's down to which line is the problem.The bugs seems to be with printf: This works: import outbuffer; int main(){ OutBuffer buf = new OutBuffer(); //printf("buf = %p\n", buf); //printf("buf.offset = %x\n", buf.offset); assert(buf.offset == 0); buf.write("hello"); buf.write(cast(byte)0x20); //buf.write("world"); // buf.printf(" %d", 6); printf("buf = '%.*s'\n", buf.toString()); return 0; } this crashes: import outbuffer; int main(){ OutBuffer buf = new OutBuffer(); //printf("buf = %p\n", buf); //printf("buf.offset = %x\n", buf.offset); assert(buf.offset == 0); buf.write("hello"); buf.write(cast(byte)0x20); //buf.write("world"); buf.printf(" %d", 6); printf("buf = '%.*s'\n", buf.toString()); return 0; } Regards Friedrich
Aug 24 2003