JclSysInfo causing programs freeze under Win8.1#116
JclSysInfo causing programs freeze under Win8.1#116PizzaProgram wants to merge 1 commit intoproject-jedi:masterfrom
Conversation
Under Windows 8.1 Embedded Industrial Enterprice (Build 9600) the GetWindowsMajorVersionNumber() causing: `EConvertError: '' is not a valid integer value.` It is reckless to call unsafe code from initialization part!
ronaldhoek
left a comment
There was a problem hiding this comment.
This file is now in UTF-8 encoding and should be ANSI encoding
|
I've clicked only the "Edit" here on github and edited. |
|
@PizzaProgram yes, that's a known thing. |
|
The StrToInt code in GetWindowsMajorVersionNumber was changed to StrToIntDef in August 2016. |
|
@ahausladen jcl/jcl/source/common/JclSysInfo.pas Line 4167 in 47af4fe That code is unsafe this way.
I haven't searched the entire unit, but I guess there are other functions like this too. |
|
@ronaldhoek |
|
This pull request fixes the symptoms by catching all exceptions. It would be better to fix the actual cause. The StrToIntDef that was added in 2016 prevents the EConvertError. So I made the assumption that the code base you used may have been too old. About the GetWindowsMajorVersionNumber: GetWindowsMinorVersionNumber: I found another StrToInt call in GetWindowsBuildNumber that could throw an EConvertError if the "CurrentBuildNumber" registry value exists but isn't a number. |
|
IMHO if there is no point, it should still try to convert from string to int to get the major version number. The decimal point is only a must to get the Minor version. |
|
Also, my opinion stays:
There should be always a try - except at init.. and finalization part !It is not fair, to write a component, that can freeze an app before it can even start.
|
…eeze under Win8.1 - Replaces StrToInt with StrToIntDef - Fixes possible wrong major version (returned 2 instead of Win32MajorVersion, returned 2 if the version number didn't contain a dot instead of the whole version number as major version) - Added try/except blocks
|
I've made a commit that combines the cause-fixes and adds the try/except blocks in the InitSysInfo and FinalizeSysInfo functions. |
|
I believe this can now be closed? |
Under Windows 8.1 Embedded Industrial Enterprice (Build 9600) the GetWindowsMajorVersionNumber() causing:
EConvertError: '' is not a valid integer value.It is reckless to call unsafe code from initialization part!