--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hello there,I have small go program with a bug in it, and I can't figure out what the problem is. It might be a runtime or compiler bug, though I highly doubt it. I'm posting it to the mailing list, just to be sure that the bug is in my code, if someone could help me diagnose it. I apologize if something similar has already been discussed/diagnosed on the list, but without being able to pinpoint anything of the nature of the bug, I can't really search for it.The program counts all the unique runes in a file and prints out the occurence count, sorted according to the count. I would have trimmed the program down to the bare essentials to demonstrate the bug, but every time I remove something, the bug disappears also.The program crashes at line 73, when a slice of runes is passed to sort.Sort(). The panic message says "invalid memory address or nil pointer dereference", but it doesn't print a stacktrace. I tried to prod the corpse with gdb, but neither did that give me any useful info. Then again, in gdb, when I print the value of the runeslice, it prints weird stuff for the address of the underlying array, or sometimes for the len field of the slice.Okay, so summary questions:-why does the code panic?-why is there no stacktrace?-why does gdb print out weird stuff when examining the runeslice at uniqc:71 ?src and some debug output:
Hello there,
I have small go program with a bug in it, and I can't figure out what the problem is. It might be a runtime or compiler bug, though I highly doubt it. I'm posting it to the mailing list, just to be sure that the bug is in my code, if someone could help me diagnose it. I apologize if something similar has already been discussed/diagnosed on the list, but without being able to pinpoint anything of the nature of the bug, I can't really search for it.
The program counts all the unique runes in a file and prints out the occurence count, sorted according to the count. I would have trimmed the program down to the bare essentials to demonstrate the bug, but every time I remove something, the bug disappears also.
The program crashes at line 73, when a slice of runes is passed to sort.Sort(). The panic message says "invalid memory address or nil pointer dereference", but it doesn't print a stacktrace. I tried to prod the corpse with gdb, but neither did that give me any useful info. Then again, in gdb, when I print the value of the runeslice, it prints weird stuff for the address of the underlying array, or sometimes for the len field of the slice.
Okay, so summary questions:-why does the code panic?-why is there no stacktrace?-why does gdb print out weird stuff when examining the runeslice at uniqc:71 ?
src and some debug output: