Closed zzz125 closed 7 years ago
use-of-uninitialized-value
Is it possible to see which lines of code, or variable names it's referring to?
@shurcooL
I can't test it right now. For me its a non-issue currently, but i think it could be a bug or something. Maybe someone else can test this in future.
It looks like -msan
flag is Linux only:
https://github.com/golang/go/blob/go1.6.2/src/runtime/msan/msan.go#L5
So someone with Linux would need to look into it.
Tested on Ubuntu 16.04.
I can reproduce this here. Here is a go tool objdump
run on the binary. dump.gz
==31406==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x6ff345 (/home/pwaller/.local/src/github.com/go-gl/examples/gl41core-cube/gl41core-cube+0x6ff345)
#1 0x6ed1dd (/home/pwaller/.local/src/github.com/go-gl/examples/gl41core-cube/gl41core-cube+0x6ed1dd)
#2 0x71b91f (/home/pwaller/.local/src/github.com/go-gl/examples/gl41core-cube/gl41core-cube+0x71b91f)
#3 0x4f06cf (/home/pwaller/.local/src/github.com/go-gl/examples/gl41core-cube/gl41core-cube+0x4f06cf)
SUMMARY: MemorySanitizer: use-of-uninitialized-value (/home/pwaller/.local/src/github.com/go-gl/examples/gl41core-cube/gl41core-cube+0x6ff345)
#0
is the msan crash thunk. #1
is glfwInit
, #2
is _cgo_4c81a0848e0b_Cfunc_glfwInit
but the stack return address appears to be one byte short of an instruction.
Unfortunately, I can't reproduce this with plain-old-c. In a subdirectory of the cube example I did the following, compiling glfw in the same way that go does, from sources shipped with the go glfw package.
With a main.c:
#include <glfw3.h>
#include <stdio.h>
int main(int argc, char const *argv[]) {
glfwInit();
return 0;
}
So, the long and short of it is, I'm not sure what is triggering this.
My first attempt at using gdb didn't get anywhere and just resulted in segfaults. But for some reason it's working now. I was able to hit it while single stepping.
So it looks like the problematic line is line 498 of x11_init.c.
if (!sr->ncrtc || !XRRGetCrtcGammaSize(_glfw.x11.display, sr->crtcs[0]))
Ah wait, msan
!= -fsanitize=address
.
If I use -fsanitize=memory
, then the c program fails too:
Uninitialized bytes in read_iovec at offset 0 inside [0x70400000ec60, 18)
==1969==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x429e88 (/home/pwaller/.local/src/github.com/go-gl/examples/gl41core-cube/init/a.out+0x429e88)
#1 0x7f997d193f28 (/usr/lib/x86_64-linux-gnu/libxcb.so.1+0x9f28)
#2 0x7f997d19431c (/usr/lib/x86_64-linux-gnu/libxcb.so.1+0xa31c)
#3 0x7f997d193a57 (/usr/lib/x86_64-linux-gnu/libxcb.so.1+0x9a57)
#4 0x7f997d197610 (/usr/lib/x86_64-linux-gnu/libxcb.so.1+0xd610)
#5 0x7f997f241809 (/usr/lib/x86_64-linux-gnu/libX11.so.6+0x3c809)
#6 0x7f997f232391 (/usr/lib/x86_64-linux-gnu/libX11.so.6+0x2d391)
#7 0x4b4172 (/home/pwaller/.local/src/github.com/go-gl/examples/gl41core-cube/init/a.out+0x4b4172)
#8 0x4936ba (/home/pwaller/.local/src/github.com/go-gl/examples/gl41core-cube/init/a.out+0x4936ba)
#9 0x48928c (/home/pwaller/.local/src/github.com/go-gl/examples/gl41core-cube/init/a.out+0x48928c)
#10 0x7f997d8e682f (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
#11 0x41bd88 (/home/pwaller/.local/src/github.com/go-gl/examples/gl41core-cube/init/a.out+0x41bd88)
SUMMARY: MemorySanitizer: use-of-uninitialized-value (/home/pwaller/.local/src/github.com/go-gl/examples/gl41core-cube/init/a.out+0x429e88)
It might not be the same failure. But until someone can demonstrate that this is the go library's fault, I think we must conclude it is not for now. If this is a problem for you, please follow it up upstream. Given that the C program which just calls glfwInit fails, it seems unlikely that there is a quick fix on our side.
Thanks for reporting, but I will close this for now unless anyone follows up with further evidence and an actionable bug report.
I just tried to run gl21 example with the new -msan option and it gives error (other projects give the same error)
==18024==WARNING: MemorySanitizer: use-of-uninitialized-value
0 0x7a2877 (/tmp/go-build517668219/command-line-arguments/_obj/exe/cube+0x7a2877)
The command was: $ CC=clang-3.8 go run -v -msan cube.go
go 1.6 clang 3.8 llvm 3.8 ubuntu 16.04
Should it even work or not? I have (almost) no other problems with these bindings. Just curious.