Skip Menu |

This queue is for tickets about the Sys-CPU CPAN distribution.

Report information
The Basics
Id: 105265
Status: new
Priority: 0/
Queue: Sys-CPU

People
Owner: Nobody in particular
Requestors: Ralf.Neubauer [...] wido.bv.aok.de
Cc:
AdminCc:

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



Subject: cpu_type() doesn't work under Windows
Date: Tue, 16 Jun 2015 14:39:03 +0000
To: "bug-Sys-CPU [...] rt.cpan.org" <bug-Sys-CPU [...] rt.cpan.org>
From: "Neubauer, Ralf" <ralf.neubauer [...] wido.bv.aok.de>
Version: 0.61 Hi, I get: Test Summary Report ------------------- t/Sys-CPU.t (Wstat: 0 Tests: 4 Failed: 1) Failed test: 4 Files=1, Tests=4, 0 wallclock secs ( 0.03 usr + 0.03 sys = 0.06 CPU) Result: FAIL under Windows cpu_type() expands to: cpu_type() CODE: { char *value = NULL; if (GetSysInfoKey("Identifier", value)) { value = NULL; } if (value) { ST(0) = sv_newmortal(); sv_setpv (ST(0), value); } else { ST(0) = &PL_sv_undef; } } Note GetSysInfoKey is called with output = value = NULL. The function call can't change the value pointer, only the data contained in value (which would crash, but see below), and cpu_type() returns undef. In GetSysInfoKey() output is never allocated, but passed to RegQueryValueEx() as follows: ret = RegQueryValueEx(hSubKey, key_name, NULL, &dwRegType, output, &dwBuffSize); The documentation of this function (e.g. https://msdn.microsoft.com/en-us/library/windows/desktop/ms724911%28v=vs.85%29.aspx ) says: lpData [out, optional] A pointer to a buffer that receives the value's data. This parameter can be NULL if the data is not required. Thus GetSysInfoKey() doesn't crash, but value of course stays NULL and undef is returned. The same documentation says: To ensure that any string values (REG_SZ, REG_MULTI_SZ, and REG_EXPAND_SZ) returned are null-terminated, use the RegGetValue function. Ralf