Build broken
/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c: In function 'coroutine_new':/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:160:16: error: 'arg.i[1]' may be used uninitialized in this function /home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:136:18: note: 'arg.i[1]' was declared here
coroutine-ucontext.c +1 -1
@@ -133,7 +133,7 @@ static Coroutine *coroutine_new(void)CoroutineUContext *co;ucontext_t old_uc, uc;jmp_buf old_env; -union cc_arg arg; +union cc_arg arg = {0 };/* The ucontext functions preserve signal masks which incurs a system call * overhead. setjmp()/longjmp() does not preserve signal masks but only
I guess gcc should yell not only here on ppc32 but on any machine where pointer size is less than the size of two ints.
Signature · 1 line
mailto:[email protected]
Am 05.08.2011 08:22, schrieb malc:
Quoted 19 lines
/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c: In function 'coroutine_new':/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:160:16: error: 'arg.i[1]' may be used uninitialized in this function/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:136:18: note: 'arg.i[1]' was declared herecoroutine-ucontext.c +1
-1@@ -133,7 +133,7 @@ static Coroutine *coroutine_new(void)CoroutineUContext *co;ucontext_t old_uc, uc;jmp_buf old_env; -union cc_arg arg; +union cc_arg arg = {0 };/* The ucontext functions preserve signal masks which incurs a system call * overhead. setjmp()/longjmp() does not preserve signal masks but only
Quoted 2 lines
I guess gcc should yell not only here on ppc32 but on any machine where pointer size is less than the size of two ints.
Stefan, why does this code even exist again? I think at some point I had it changed to just use a static variable in order to avoid doing this kind of tricks with unions.
Interestingly, the buildbot doesn't seem to have failed on i386.
Kevin
Quoted 20 lines · Kevin Wolf
Am 05.08.2011 08:22, schrieb malc:
Quoted 19 lines
/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c: In function 'coroutine_new':/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:160:16: error: 'arg.i[1]' may be used uninitialized in this function/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:136:18: note: 'arg.i[1]' was declared herecoroutine-ucontext.c +1
-1@@ -133,7 +133,7 @@ static Coroutine *coroutine_new(void) CoroutineUContext *co; ucontext_t old_uc, uc; jmp_buf old_env; - union cc_arg arg; + union cc_arg arg = {0}; /* The ucontext functions preserve signal masks which incurs a system call* overhead. setjmp()/longjmp() does not preserve signal masks but only
Quoted 6 lines
Quoted 2 lines
I guess gcc should yell not only here on ppc32 but on any machine where pointer size is less than the size of two ints.
Stefan, why does this code even exist again? I think at some point I had it changed to just use a static variable in order to avoid doing this kind of tricks with unions.
virtfs are using coroutines in multiple threads at the same time. Introducing a global variable wouldn't be thread-safe.
The real problem is that makecontext(3) has a bad function signature. There's no nice fix - whatever we do will be ugly.
Using a union is the way it should be done in C. The code doesn't look pretty but it doesn't introduce global state.
Stefan
Am 05.08.2011 10:48, schrieb Stefan Hajnoczi:
Quoted 28 lines · Kevin Wolf
Quoted 20 lines
Am 05.08.2011 08:22, schrieb malc:
Quoted 19 lines
/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c: In function 'coroutine_new':/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:160:16: error: 'arg.i[1]' may be used uninitialized in this function/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:136:18: note: 'arg.i[1]' was declared herecoroutine-ucontext.c +1
-1@@ -133,7 +133,7 @@ static Coroutine *coroutine_new(void)CoroutineUContext *co;ucontext_t old_uc, uc;jmp_buf old_env; -union cc_arg arg; +union cc_arg arg = {0 };/* The ucontext functions preserve signal masks which incurs a system call * overhead. setjmp()/longjmp() does not preserve signal masks but only Quoted 6 lines
Quoted 2 lines
I guess gcc should yell not only here on ppc32 but on any machine where pointer size is less than the size of two ints.
Stefan, why does this code even exist again? I think at some point I had it changed to just use a static variable in order to avoid doing this kind of tricks with unions.
Quoted 8 lines
virtfs are using coroutines in multiple threads at the same time. Introducing a global variable wouldn't be thread-safe.
The real problem is that makecontext(3) has a bad function signature. There's no nice fix - whatever we do will be ugly.
Using a union is the way it should be done in C. The code doesn't look pretty but it doesn't introduce global state.
But it makes assumptions about the pointer size, which isn't a nice thing. TLS isn't an option for compatibility with some OSes/architectures?
Kevin
Quoted 32 lines · Kevin Wolf
Am 05.08.2011 10:48, schrieb Stefan Hajnoczi:
Quoted 31 lines · Kevin Wolf
Quoted 20 lines
Am 05.08.2011 08:22, schrieb malc:
Quoted 19 lines
/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c: In function 'coroutine_new':/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:160:16: error: 'arg.i[1]' may be used uninitialized in this function/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:136:18: note: 'arg.i[1]' was declared herecoroutine-ucontext.c +1
-1@@ -133,7 +133,7 @@ static Coroutine *coroutine_new(void) CoroutineUContext *co; ucontext_t old_uc, uc; jmp_buf old_env; - union cc_arg arg; + union cc_arg arg = {0}; /* The ucontext functions preserve signal masks which incurs a system call* overhead. setjmp()/longjmp() does not preserve signal masks but only Quoted 6 lines
Quoted 2 lines
I guess gcc should yell not only here on ppc32 but on any machine where pointer size is less than the size of two ints.
Stefan, why does this code even exist again? I think at some point I had it changed to just use a static variable in order to avoid doing this kind of tricks with unions.
virtfs are using coroutines in multiple threads at the same time. Introducing a global variable wouldn't be thread-safe.
Quoted 8 lines
Quoted 5 lines
The real problem is that makecontext(3) has a bad function signature. There's no nice fix - whatever we do will be ugly.
Using a union is the way it should be done in C. The code doesn't look pretty but it doesn't introduce global state.
But it makes assumptions about the pointer size, which isn't a nice thing. TLS isn't an option for compatibility with some OSes/architectures?
GThread TLS is portable but slow in my testing.
You are right, when we move to 128-bit pointers this code will break :). We could at add a #warning if pointer size > 64-bits.
Stefan
Quoted 19 lines · malc
/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c: In function 'coroutine_new':/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:160:16: error: 'arg.i[1]' may be used uninitialized in this function/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:136:18: note: 'arg.i[1]' was declared herecoroutine-ucontext.c +1
-1@@ -133,7 +133,7 @@ static Coroutine *coroutine_new(void) CoroutineUContext *co; ucontext_t old_uc, uc; jmp_buf old_env; - union cc_arg arg; + union cc_arg arg = {0}; /* The ucontext functions preserve signal masks which incurs a system call* overhead. setjmp()/longjmp() does not preserve signal masks but only
Quoted 2 lines
I guess gcc should yell not only here on ppc32 but on any machine where pointer size is less than the size of two ints.
Makes sense. Are you going to commit a fix or send a signed-off-by patch?
Stefan
Quoted 17 lines · Stefan Hajnoczi
Quoted 16 lines · malc
/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c: In function 'coroutine_new':/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:160:16: error: 'arg.i[1]' may be used uninitialized in this function/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:136:18: note: 'arg.i[1]' was declared herecoroutine-ucontext.c +1
-1@@ -133,7 +133,7 @@ static Coroutine *coroutine_new(void) CoroutineUContext *co; ucontext_t old_uc, uc; jmp_buf old_env; - union cc_arg arg; + union cc_arg arg = {0};
Quoted 8 lines
Quoted 5 lines
coroutine-ucontext.c +0
-0/* The ucontext functions preserve signal masks which incurs a system call* overhead. setjmp()/longjmp() does not preserve signal masks but only I guess gcc should yell not only here on ppc32 but on any machine where pointer size is less than the size of two ints.
Makes sense. Are you going to commit a fix or send a signed-off-by patch?
If the author(s)(you and Kevin? just you?) agree with the above i can just push it.
Signature · 1 line
mailto:[email protected]
Quoted 22 lines · malc
Quoted 20 lines · Stefan Hajnoczi
Quoted 19 lines · malc
/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c: In function 'coroutine_new':/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:160:16: error: 'arg.i[1]' may be used uninitialized in this function/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:136:18: note: 'arg.i[1]' was declared herecoroutine-ucontext.c +1
-1@@ -133,7 +133,7 @@ static Coroutine *coroutine_new(void) CoroutineUContext *co; ucontext_t old_uc, uc; jmp_buf old_env; - union cc_arg arg; + union cc_arg arg = {0}; /* The ucontext functions preserve signal masks which incurs a system call* overhead. setjmp()/longjmp() does not preserve signal masks but only
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I guess gcc should yell not only here on ppc32 but on any machine where pointer size is less than the size of two ints.
Makes sense. Are you going to commit a fix or send a signed-off-by patch?
If the author(s)(you and Kevin? just you?) agree with the above i can just push it.
The change makes sense to me.
Kevin?
Stefan
Kevin Wolf
Acked-byAm 05.08.2011 18:49, schrieb malc:
Quoted 22 lines · Stefan Hajnoczi
Quoted 21 lines · malc
Quoted 19 lines
/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c: In function 'coroutine_new':/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:160:16: error: 'arg.i[1]' may be used uninitialized in this function/home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:136:18: note: 'arg.i[1]' was declared herecoroutine-ucontext.c +1
-1@@ -133,7 +133,7 @@ static Coroutine *coroutine_new(void)CoroutineUContext *co;ucontext_t old_uc, uc;jmp_buf old_env; -union cc_arg arg; +union cc_arg arg = {0 };/* The ucontext functions preserve signal masks which incurs a system call * overhead. setjmp()/longjmp() does not preserve signal masks but only
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I guess gcc should yell not only here on ppc32 but on any machine where pointer size is less than the size of two ints.
Makes sense. Are you going to commit a fix or send a signed-off-by patch?
If the author(s)(you and Kevin? just you?) agree with the above i can just push it.
Feel free to push it. (Original code was by Anthony, then heavily modified by me, and after that modified again by Stefan)
Quoted 3 lines · Kevin Wolf
Am 05.08.2011 18:49, schrieb malc:
Quoted 2 lines · Stefan Hajnoczi
[..snip..]
Quoted 5 lines
Feel free to push it. (Original code was by Anthony, then heavily modified by me, and after that modified again by Stefan)
Acked-by Kevin Wolf <[email protected]>
Pushed.
Signature · 1 line
mailto:[email protected]