Re: [Linuxwacom-devel] [PATCH] Move VCOPY storage out of the function.
On Wed, Mar 02, 2011 at 10:43:34AM -0800, Ping Cheng wrote: > On Tue, Mar 1, 2011 at 4:33 PM, Peter Hutterer > wrote: > > > Not 100% sure why this is needed but it looks like the returned address is > > invalid, causing memory corruption. Simply moving the variable into a > > global > > scope fixes this issue. > > > > Fixes crash with server 1.7. > > > > Reported-by: Vu Ngoc San > > Signed-off-by: Peter Hutterer > > --- > > src/wcmCommon.c |2 +- > > 1 files changed, 1 insertions(+), 1 deletions(-) > > > > diff --git a/src/wcmCommon.c b/src/wcmCommon.c > > index e469e15..64e10cc 100644 > > --- a/src/wcmCommon.c > > +++ b/src/wcmCommon.c > > @@ -36,9 +36,9 @@ > > * data beforehand. > > */ > > #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 11 > > +static int v[MAX_VALUATORS]; > > static int *VCOPY(const int *valuators, int nvals) > > { > > - static int v[MAX_VALUATORS]; > >memcpy(v, valuators, nvals * sizeof(int)); > >return v; > > > > Once the routine is returned, the pointer is out of the scope. > > To return a valid pointer, the array has to be declared outside of VCOPY. > You could declare it in the calling routine if you don't like it as a global > variable. well, that's the bit that is confusing me. since the storage is static, why would the address to it be invalid (or even temporary)? > With that said, > > Reviewed-by: Ping Cheng thanks! Cheers, Peter -- Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
Re: [Linuxwacom-devel] [PATCH] Move VCOPY storage out of the function.
On Tue, Mar 1, 2011 at 4:33 PM, Peter Hutterer wrote: > Not 100% sure why this is needed but it looks like the returned address is > invalid, causing memory corruption. Simply moving the variable into a > global > scope fixes this issue. > > Fixes crash with server 1.7. > > Reported-by: Vu Ngoc San > Signed-off-by: Peter Hutterer > --- > src/wcmCommon.c |2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/src/wcmCommon.c b/src/wcmCommon.c > index e469e15..64e10cc 100644 > --- a/src/wcmCommon.c > +++ b/src/wcmCommon.c > @@ -36,9 +36,9 @@ > * data beforehand. > */ > #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 11 > +static int v[MAX_VALUATORS]; > static int *VCOPY(const int *valuators, int nvals) > { > - static int v[MAX_VALUATORS]; >memcpy(v, valuators, nvals * sizeof(int)); >return v; > Once the routine is returned, the pointer is out of the scope. To return a valid pointer, the array has to be declared outside of VCOPY. You could declare it in the calling routine if you don't like it as a global variable. With that said, Reviewed-by: Ping Cheng Ping -- Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
Re: [Linuxwacom-devel] [PATCH] Move VCOPY storage out of the function.
Weird. The crash sounded like the VCOPY issue but I wouldn't have guessed this the issue. Reviewed-by: Chris Bagwell Chris On Tue, Mar 1, 2011 at 6:33 PM, Peter Hutterer wrote: > Not 100% sure why this is needed but it looks like the returned address is > invalid, causing memory corruption. Simply moving the variable into a global > scope fixes this issue. > > Fixes crash with server 1.7. > > Reported-by: Vu Ngoc San > Signed-off-by: Peter Hutterer > --- > src/wcmCommon.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/src/wcmCommon.c b/src/wcmCommon.c > index e469e15..64e10cc 100644 > --- a/src/wcmCommon.c > +++ b/src/wcmCommon.c > @@ -36,9 +36,9 @@ > * data beforehand. > */ > #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 11 > +static int v[MAX_VALUATORS]; > static int *VCOPY(const int *valuators, int nvals) > { > - static int v[MAX_VALUATORS]; > memcpy(v, valuators, nvals * sizeof(int)); > return v; > } > -- > 1.7.4 > > > -- > Free Software Download: Index, Search & Analyze Logs and other IT data in > Real-Time with Splunk. Collect, index and harness all the fast moving IT data > generated by your applications, servers and devices whether physical, virtual > or in the cloud. Deliver compliance at lower cost and gain new business > insights. http://p.sf.net/sfu/splunk-dev2dev > ___ > Linuxwacom-devel mailing list > Linuxwacom-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel > -- Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
[Linuxwacom-devel] [PATCH] Move VCOPY storage out of the function.
Not 100% sure why this is needed but it looks like the returned address is invalid, causing memory corruption. Simply moving the variable into a global scope fixes this issue. Fixes crash with server 1.7. Reported-by: Vu Ngoc San Signed-off-by: Peter Hutterer --- src/wcmCommon.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/wcmCommon.c b/src/wcmCommon.c index e469e15..64e10cc 100644 --- a/src/wcmCommon.c +++ b/src/wcmCommon.c @@ -36,9 +36,9 @@ * data beforehand. */ #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 11 +static int v[MAX_VALUATORS]; static int *VCOPY(const int *valuators, int nvals) { - static int v[MAX_VALUATORS]; memcpy(v, valuators, nvals * sizeof(int)); return v; } -- 1.7.4 -- Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel