Skip Menu |
 

This queue is for tickets about the Win32-SystemInfo CPAN distribution.

Report information
The Basics
Id: 48008
Status: resolved
Priority: 0/
Queue: Win32-SystemInfo

People
Owner: cjohnston [...] cpan.org
Requestors: steven.hartland [...] multiplay.co.uk
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.11
Fixed in: (no value)



Subject: Incorrect use of Win32::API::Struct sizeof
Download (untitled) / with headers
text/plain 1020b
Within sub MemoryStatus there is the following call:- $MEMORYSTATUSEX->{dwLength} = Win32::API::Struct->sizeof($MEMORYSTATUSEX); The current call is using sizeof as a class method which results in the following warning when run under perl -w: Use of uninitialized value $first in concatenation (.) or string at Perl/site/lib/Win32/API/Struct.pm line 139. Upon inspection it can be seen that the loop is never processed hence a real size value is never calculated and 0 value is always returned. $MEMORYSTATUSEX->{dwLength} = Win32::API::Struct->sizeof($MEMORYSTATUSEX); print "dwLength = $MEMORYSTATUSEX->{dwLength}\n"; Gives:- Use of uninitialized value $first in concatenation (.) or string at Perl/site/lib/Win32/API/Struct.pm line 139. dwLength = 0 Changing it to the following fixes this: $MEMORYSTATUSEX->{dwLength} = $MEMORYSTATUSEX->sizeof(); I'm using Win32::SystemInfo v0.11 with Win32::API v0.59 on Windows 2008 R2 64bit but this will happen on any 64bit int compatible build of perl.
Download (untitled) / with headers
text/plain 871b
Show quoted text
> The current call is using sizeof as a class method which results in the > following warning when run under perl -w: > Use of uninitialized value $first in concatenation (.) or string at > Perl/site/lib/Win32/API/Struct.pm line 139.
So, the issue here is that warnings are being generated? Am I reading this correctly? There is no actual crash? Is the call returning the correct data? Show quoted text
> Changing it to the following fixes this: > $MEMORYSTATUSEX->{dwLength} = $MEMORYSTATUSEX->sizeof();
It does appear that the sizeof() sub in Win32::API::Struct differs from the one in Win32::API::Typedef, so making this change may indeed change the behavior. Show quoted text
> I'm using Win32::SystemInfo v0.11 with Win32::API v0.59 on Windows 2008 > R2 64bit but this will happen on any 64bit int compatible build of perl.
What distribution/version of Perl are you seeing this issue on?
Subject: Re: [rt.cpan.org #48008] Incorrect use of Win32::API::Struct sizeof
Date: Mon, 20 Jul 2009 01:11:17 +0100
To: <bug-Win32-SystemInfo [...] rt.cpan.org>
From: "Steven Hartland" <killing [...] multiplay.co.uk>
Download (untitled) / with headers
text/plain 1.4k
Show quoted text
----- Original Message ----- From: "Chad Johnston via RT" <bug-Win32-SystemInfo@rt.cpan.org>
> So, the issue here is that warnings are being generated? Am I reading this correctly? There is > no actual crash? Is the call returning the correct data?
No it always returns 0 as it has no access to the structure, so not sure what the result will be to the actual windows dll call, it may not harm it but it could.
>> Changing it to the following fixes this: >> $MEMORYSTATUSEX->{dwLength} = $MEMORYSTATUSEX->sizeof();
> > It does appear that the sizeof() sub in Win32::API::Struct differs from the one in > Win32::API::Typedef, so making this change may indeed change the behavior.
;-)
>> I'm using Win32::SystemInfo v0.11 with Win32::API v0.59 on Windows 2008 >> R2 64bit but this will happen on any 64bit int compatible build of perl.
> > What distribution/version of Perl are you seeing this issue on?
I was testing with 5.8 and 5.10 from Activestate. ================================================ This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it. In the event of misdirection, illegible or incomplete transmission please telephone +44 845 868 1337 or return the E.mail to postmaster@multiplay.co.uk.
Download (untitled) / with headers
text/plain 711b
Show quoted text
> > So, the issue here is that warnings are being generated? Am I
> reading this correctly? There is
> > no actual crash? Is the call returning the correct data?
> > No it always returns 0 as it has no access to the structure, so not > sure what the > result will be to the actual windows dll call, it may not harm it but > it could.
I'm still a bit confused. If I make the following call: Win32::SystemInfo::MemoryStatus(%mHash); Does the call fail? Is information returned in the hash? Is there an actual crash? Show quoted text
> I was testing with 5.8 and 5.10 from Activestate.
32- or 64-bit versions? I tried the 64-bit versions, but Win32::API isn't available by default for 64-bit because it doesn't build.
Download (untitled) / with headers
text/plain 1.6k
This appears to be the source of the test failures on Strawberry Perl 5.16.2.1. Can't use string ("Win32::API::Struct") as a HASH ref while "strict refs" in use at C:/strawberry/perl/site/lib/ /Struct.pm line 158. dmake.EXE: Error code 255, while making 'test_dynamic' CJOHNSTON/Win32-SystemInfo-0.11.zip C:\strawberry\c\bin\dmake.EXE test -- NOT OK When the change outlined above is made, this error goes away and we see the following: C:\strawberry\cpan\build\Win32-SystemInfo-0.11-PL12Cm>dmake cp SystemInfo.pm blib\lib\Win32\SystemInfo.pm C:\strawberry\cpan\build\Win32-SystemInfo-0.11-PL12Cm>dmake test C:\strawberry\perl\bin\perl.exe "-Iblib\lib" "-Iblib\arch" test.pl 1..3 ok 1 Use of uninitialized value in pack at C:/strawberry/perl/vendor/lib/Win32/API/St ruct.pm line 317. Use of uninitialized value in pack at C:/strawberry/perl/vendor/lib/Win32/API/St ruct.pm line 317. Use of uninitialized value in pack at C:/strawberry/perl/vendor/lib/Win32/API/St ruct.pm line 317. Use of uninitialized value in pack at C:/strawberry/perl/vendor/lib/Win32/API/St ruct.pm line 317. Use of uninitialized value in pack at C:/strawberry/perl/vendor/lib/Win32/API/St ruct.pm line 317. Use of uninitialized value in pack at C:/strawberry/perl/vendor/lib/Win32/API/St ruct.pm line 317. Use of uninitialized value in pack at C:/strawberry/perl/vendor/lib/Win32/API/St ruct.pm line 317. Use of uninitialized value in pack at C:/strawberry/perl/vendor/lib/Win32/API/St ruct.pm line 317. ok 2 Can't call method "GetValue" on an undefined value at blib\lib/Win32/SystemInfo. pm line 355. dmake: Error code 255, while making 'test_dynamic'
On Sat Feb 09 13:09:30 2013, MMUSGROVE wrote: Show quoted text
> This appears to be the source of the test failures on Strawberry Perl > 5.16.2.1. > > Can't use string ("Win32::API::Struct") as a HASH ref while
"strict Show quoted text
> refs" in use at C:/strawberry/perl/site/lib/ > /Struct.pm line 158. > dmake.EXE: Error code 255, while making 'test_dynamic' > CJOHNSTON/Win32-SystemInfo-0.11.zip > C:\strawberry\c\bin\dmake.EXE test -- NOT OK > > When the change outlined above is made, this error goes away and we
see Show quoted text
> the following: > C:\strawberry\cpan\build\Win32-SystemInfo-0.11-PL12Cm>dmake > cp SystemInfo.pm blib\lib\Win32\SystemInfo.pm > > C:\strawberry\cpan\build\Win32-SystemInfo-0.11-PL12Cm>dmake test > C:\strawberry\perl\bin\perl.exe "-Iblib\lib" "-Iblib\arch"
test.pl Show quoted text
> 1..3 > ok 1 > Use of uninitialized value in pack at > C:/strawberry/perl/vendor/lib/Win32/API/St > ruct.pm line 317. > Use of uninitialized value in pack at > C:/strawberry/perl/vendor/lib/Win32/API/St > ruct.pm line 317. > Use of uninitialized value in pack at > C:/strawberry/perl/vendor/lib/Win32/API/St > ruct.pm line 317. > Use of uninitialized value in pack at > C:/strawberry/perl/vendor/lib/Win32/API/St > ruct.pm line 317. > Use of uninitialized value in pack at > C:/strawberry/perl/vendor/lib/Win32/API/St > ruct.pm line 317. > Use of uninitialized value in pack at > C:/strawberry/perl/vendor/lib/Win32/API/St > ruct.pm line 317. > Use of uninitialized value in pack at > C:/strawberry/perl/vendor/lib/Win32/API/St > ruct.pm line 317. > Use of uninitialized value in pack at > C:/strawberry/perl/vendor/lib/Win32/API/St > ruct.pm line 317. > ok 2 > Can't call method "GetValue" on an undefined value at > blib\lib/Win32/SystemInfo. > pm line 355. > dmake: Error code 255, while making 'test_dynamic'
I've made this change, and I still get the above errors on ActivePerl 5.14. I can't call this a fix yet, so I'll dig in to it as I get more time. I've started a feature branch at https://github.com/iamthechad/perl- win32-systeminfo/tree/v012 with these changes in case anybody wants to take a look at it.
This has been resolved in Win32::SystemInfo 0.12, which was uploaded to PAUSE on 16 Feb 2013.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.