AutoHotkey Community

It is currently May 27th, 2012, 8:25 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: February 1st, 2012, 9:46 pm 
Online

Joined: February 19th, 2010, 8:07 pm
Posts: 615
Hi guys,

well as the title says if you omit the section option but still provide a key option Autohotkey L crashes which in general shouldnt be, i would expect an error or any other type of message.

Code:
iniread, var, test.ini,,new ; this crashes L (ansi & unicode), file enconding is ansi
msgbox % var

_________________
Main Project: AutoHotkey Toolkit
Unless specified otherwise all my code is written for the latest Autohotkey L Unicode version.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 6th, 2012, 12:46 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
With this INI file, it returned the word "ERROR":
Code:
[section]
key=value
With this INI file, it returned the value "123":
Code:
[]
new=123
So you see, an empty section name is also valid.

And no, it did not crash.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 6th, 2012, 7:59 pm 
Lexikos wrote:
And no, it did not crash.

I can make it crash too! :D or :cry: depending how you look at it. This test script makes it crash. I think.
Code:
ini=
(
[2]
var=hello
)
filedelete, test.ini
fileappend, %ini%, test.ini

iniread, var, test.ini,,new ; this crashes L (ansi & unicode), file enconding is ansi
msgbox % var

v1.1.05.06


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 6th, 2012, 10:29 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Nope, that didn't crash either. It just set var to the default value, as it was supposed to.
Quote:
I think.
Does it crash or not?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 6th, 2012, 10:54 pm 
Yes, I get a Microsoft error window with:

AutoHotkey_L has encountered a problem and needs to close. We are sorry for the inconvenience.
If you were in the middle of something, the information you were working on might be lost.
We have created an error report that you can send to us. We will treat this report as confidential and anonymous.
To see what data this error report contains...

Error report contains:

AppName: autohotkey.exe AppVer: 1.1.5.1 ModName: ntdll.dll
ModVer: 5.1.2600.6055 Offset: 000120e6

Using Windows XP, so that might help.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2012, 6:19 am 
Offline
User avatar

Joined: December 20th, 2004, 12:19 pm
Posts: 798
Location: LooseChange911.com Ask Questions, Demand Answers █ The WTC bldgs █ shouldn't have fallen █ that fast
Anonymous wrote:
Error report contains:

AppName: autohotkey.exe AppVer: 1.1.5.1

...version 1.1.5.1 is not 1.1.05.06. I still have version 1.1.05.01 & it does not crash (with that exact test script).

But there's seems to be ALOT of confusion going on...(or at least, I'm confused)...so lets get real specific...
  • What OS?
  • Which version of AutoHotkey?
  • Is AutoHotkey ANSI or Unicode?
  • Is the problem ini file ANSI or Unicode?
...some of that is covered above, in pieces (& by different people?), but if everyone who CAN get the crash would fill out the above info, that would help.

Also, if you CAN get the crash, reboot your computer & try again...sometimes Windows gets "irritated" & will continue to crash until a reboot (cuz of memory corruption {or something} from a previous crash).

_________________
AutoHotkey-Hotstring.ahk - Helping the world spell "AutoHotkey" correctly! (btw, it's a lowercase k!)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2012, 6:30 am 
Offline
User avatar

Joined: May 28th, 2011, 9:03 am
Posts: 466
Location: Germany
Code:
ini=
(
[2]
var=hello
)
filedelete, test.ini
fileappend, %ini%, test.ini

iniread, var, test.ini,,new ; this crashes L (ansi & unicode), file enconding is ansi
msgbox % var


reports ERROR when run as script and crashes when run as exe.
AHK 1.1.05.06 (U32), Win Vista 32, "test.ini" encoding is ANSI.

Code:
filedelete, test.ini
iniwrite, hello, test.ini, 2, var
iniread, var, test.ini,,new ; this crashes L (ansi & unicode), file enconding is ansi
msgbox % var

crashes when run as script and crashes when run as exe.
AHK 1.1.05.06 (U32), Win Vista 32, "test.ini" encoding is UNICODE.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2012, 7:19 am 
Offline
User avatar

Joined: December 20th, 2004, 12:19 pm
Posts: 798
Location: LooseChange911.com Ask Questions, Demand Answers █ The WTC bldgs █ shouldn't have fallen █ that fast
just me wrote:
crashes when run as script and crashes when run as exe.

...CONFIRMED...this script does crash...

Code:
FileDelete, test.ini
IniWrite, hello, test.ini, 2, var
IniRead, var, test.ini, , test

msgbox, var(%var%)

...on...
  • OS - WinXP 32-bit
  • AutoHotkey - 1.1.05.01 Unicode AND 1.1.05.06 Unicode
  • ini encoding: Unicode BOM
  • Crashes when compiled or not
...& also on...
  • OS - WinXP 32-bit
  • AutoHotkey - 1.1.05.01 ANSI AND 1.1.05.06 ANSI
  • ini encoding: ANSI
  • Crashes when compiled or not
      * however, I couldn't download the old ANSI version of Ahk2Exe (or more specifically, I couldn't download version 1.1.05.01 of "ANSI 32-bit.bin" to use in Ahk2Exe), then I found it in my installed dir of 1.1.05.01 -- why are old versions of Ahk2Exe (& the *.bins) not available?
I cannot get the 1st script to crash, still testing.

_________________
AutoHotkey-Hotstring.ahk - Helping the world spell "AutoHotkey" correctly! (btw, it's a lowercase k!)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2012, 8:41 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
As far as I can ascertain, AutoHotkey is calling GetPrivateProfileString with valid parameters on a correctly-formed INI file, and the crash occurs within that function. Perhaps Microsoft did not anticipate empty section names, and only luck allows it to work some of the time. IniRead required a non-empty Section up until the parameter was made optional to support retrieving a list of section names. Since IniWrite requires Section to be non-blank, some additional validation for IniRead seems in order (expect it in the next release).

Thank you for your perseverence, and more importantly, for providing enough detail to reproduce the problem.

Edit: I may have found a simpler, better solution. Are any of you able to reproduce a crash using %A_Space% as the section name? Leading and trailing spaces in section names seem to be ignored, except when the section is being created. So A_Space matches [], [ ], etc. If a crash cannot be reproduced, I will add the following simple check in IniRead:
Code:
      if (!*aSection)
         aSection = _T(" ");


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2012, 10:21 am 
Offline
User avatar

Joined: May 28th, 2011, 9:03 am
Posts: 466
Location: Germany
Code:
filedelete, test.ini
iniwrite, hello, test.ini, 2, var
iniread, var, test.ini,,new
msgbox % var
Crashes on Win XP SP3 (32) + AHK 1.1.05.02 (U32), compiled or not.
Code:
filedelete, test.ini
iniwrite, hello, test.ini, 2, var
iniread, var, test.ini, %A_Space% , new
msgbox % var
Doesn't crash on Win XP SP3 (32) + AHK 1.1.05.02 (U32), compiled or not.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2012, 6:24 pm 
Online

Joined: February 19th, 2010, 8:07 pm
Posts: 615
Confirmed this script crashes on both versions:
Code:
msgbox % a_ahkversion ; 1.1.05.06 ANSI & UNICODE
FileDelete, test.ini
IniWrite, hello, test.ini, 2, var
IniRead, var, test.ini, , test

msgbox, var(%var%)


While adding %a_space% on the parameter 'fixes' the issue.

Sorry for the lack of information on the OP... found the bug at 4am while rushing some code trying to go to sleep :roll:

and the messaging system from the site sucks... you guys had a whole conversation here and now i got the first msg saying that there was a reply :lol:

_________________
Main Project: AutoHotkey Toolkit
Unless specified otherwise all my code is written for the latest Autohotkey L Unicode version.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2012, 8:24 pm 
Confirmed, adding A_space results in ERROR and not a crash.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 13th, 2012, 12:44 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
I had intended to include a fix in v1.1.06.00, but it slipped my mind.

This is the working solution I've come up with (the one I mentioned earlier didn't work for reasons explained below):
Code:
   TCHAR   szEmpty[] = _T("");
...
      // An access violation can occur if the following conditions are met:
      //   1) aFilespec specifies a Unicode file.
      //   2) aSection is a
read-only string, either empty or containing only spaces.
      //
      // Debugging at the assembly level indicates that in this specific situation,
      // it tries to write a zero at the end of aSection (which is already null-
      // terminated).
      //
      // The second condition can ordinarily only be met if Section is omitted,
      // since in all other cases aSection is writable.  Although Section was a
      // required parameter prior to revision 57, empty or blank section names
      // are actually valid.  Simply passing an empty writable buffer appears
      // to work around the problem effectively:

      if (!*aSection)
         aSection = szEmpty;


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group