Old 21st September 2011, 16:53   #1
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
Debugging advice

i'm suffering over a problem occuring with my script and i'm having a difficult time pinpointing it. what this script does is locating and copying some files and using textreplace. in most cases it works without problems, but when a large number of files is involved (in my case 2530) the installer will freeze. to make things worse this does not happen always, just occasionally.

i'm looking for some hints on how to find the bug. i've already disabled various parts of the script, but without gaining any knowledge. all i can say is, this happens when working with a lot of files and i believe i did not have this problem when using other (slower) functions to replace text or to locate files. is there anything wrong with my textreplace calls? can they be optimized? any other tips on how to narrowing down the problem?

any help is greatly appreciated.
Attached Files
File Type: 7z makeinstaller.7z (9.9 KB, 119 views)
Yathosho is offline   Reply With Quote
Old 21st September 2011, 20:44   #2
{_trueparuex^}
Senior Member
 
{_trueparuex^}'s Avatar
 
Join Date: Dec 2005
Location: Glow
Posts: 285
In cases like this I usually just add some messgeboxes to the code to find the point where things go wrong, but in this case Nsisdbg plug-in is probably much better choice.

With Nsisdbg plug-in use the nsisdbg::sendtolog call to track the progress of your script.

Edit: I just realized that the Nsisdbg plug-in download link is is dead. I uploaded the plug-in on my site.

The guy with the ridiculous username. Thou shall call him PaR instead.
Visit My Website
{_trueparuex^} is offline   Reply With Quote
Old 22nd September 2011, 08:25   #3
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
i shall also note that i only get those problems on windows 7 (both 32 and 64 bit), not on windows xp.
Yathosho is offline   Reply With Quote
Old 22nd September 2011, 17:02   #4
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
thanks {_trueparuex^}, i actually tried all of this before - to no success. as i suspect the number of files to be responsible, i wonder if this could be a memory issue. i do have 8gb ram and enough space on all drives, so that should not be the case. i'm also not exceeding the string-length (i'm using the large string build), so i wonder where else i can look. what puzzles me, why does it work on xp in a virtual machine (with 2gb ram)
Yathosho is offline   Reply With Quote
Old 30th September 2011, 10:24   #5
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
it appears i could find the problem in my script, so i wanted to resolve it in case someone runs into similar problems.

the problem appeared (occasionally, only on windows vista or later) when setting the outdir when the path existed already
code:
SetOutPath "$MyTempDir\fonts"

a simple IfFileExists fixed the issue, but i changed the code to this
code:
IfFileExists "$MyTempDir\fonts\*.*" +2
CreateDirectory "$MyTempDir\fonts"


in the following a couple of files were copied, so i didn't really need SetOutPath and changed it to CreateDirectory. for reasons unknown, it was IfFileExists that made the difference!
Yathosho is offline   Reply With Quote
Old 30th September 2011, 20:03   #6
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
i continue to have this bug at a later point. again it's caused by a simple copy operation, just this time i can't figure out when and why it's happening (again it happens occasionally and only on vista/win7.) i have a test scenario which helps me testing this on 312 examples, but the result continue to be entirely random, though certain test-files tend to trigger the bug more often.

the line in question is this:
code:
CopyFiles /SILENT "$EXEDIR\ape\addborder.ape" "$MyTempDir\ape\addborder.ape"

the source-file is located in $PROGRAMFILES and is a dll with a different file-extension. the problem appears on elevated and usermode installers.

any clues, cause i'm clueless!
Attached Files
File Type: log crash.log (564 Bytes, 140 views)
Yathosho is offline   Reply With Quote
Old 1st October 2011, 19:01   #7
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
here are a couple of things i tried

1. extract the file from the installer rather than copying it -> works
2. copying the file using the full path as on my system -> works
3. checking if the source-file and the target-folder exist -> yes
4. checking if $EXEDIR is correct -> yes

$EXEDIR = C:\Program Files (x86)\whyEye.org\PimpBot\ape

CopyFile "$EXEDIR\ape\addborder.ape" "$MyTempDir\ape\addborder" -> crashes installer
CopyFile "C:\Program Files (x86)\whyEye.org\PimpBot\ape\addborder.ape" "$MyTempDir\ape\addborder" -> works

i'm clueless, please please help me!
Yathosho is offline   Reply With Quote
Old 1st October 2011, 20:45   #8
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
What if you call API directly, instead of CopyFiles?
MSG is offline   Reply With Quote
Old 1st October 2011, 22:22   #9
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
i tried StdUtils, which also results in a crash
Yathosho is offline   Reply With Quote
Old 2nd October 2011, 07:46   #10
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Just a random thought: Have you tried this on other PCs? Win Vista/7 are very clunky with file copying. It's possible that bad RAM or a bad HDD causes it to blow.
MSG is offline   Reply With Quote
Old 2nd October 2011, 09:44   #11
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
i asked some friends to test it, but they didn't get any problems (well, i'd love to test it myself). i replaced my ram since this first came up and i tried various disks including ssd, harddrives and ramdisk (hence i'm using $MyTempDir instead of $PLUGINSDIR). i have another windows 7 (32-bit) running in a virtual machine (same problem) and also windows xp (where i NEVER get this problem.) i'm going to install windows 7 on vmware on my laptop and see what happens..

further, i've tested various nsis builds (standard and longstr)

it's interesting that there have been reports regarding CopyFiles and windows 7 on this forum, though i didn't find a case that really crashes the installer.

having found the exact line where this problem occurs, i wonder if it could still be caused by something else. not sure what i should be looking for.
Yathosho is offline   Reply With Quote
Old 2nd October 2011, 11:35   #12
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
same thing on the other computer
Attached Thumbnails
Click image for larger version

Name:	w7_on_osx.jpg
Views:	140
Size:	100.0 KB
ID:	49184  
Yathosho is offline   Reply With Quote
Old 3rd October 2011, 05:51   #13
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Quote:
Originally Posted by Yathosho View Post
$EXEDIR = C:\Program Files (x86)\whyEye.org\PimpBot\ape

CopyFile "$EXEDIR\ape\addborder.ape" "$MyTempDir\ape\addborder" -> crashes installer
CopyFile "C:\Program Files (x86)\whyEye.org\PimpBot\ape\addborder.ape" "$MyTempDir\ape\addborder" -> works
It shouldn't lead to a crash, but if $EXEDIR already has a trailing 'ape', your copyfile command is wrong.
MSG is offline   Reply With Quote
Old 3rd October 2011, 09:07   #14
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
Quote:
Originally Posted by MSG View Post
It shouldn't lead to a crash, but if $EXEDIR already has a trailing 'ape', your copyfile command is wrong.
just a typo in the post

anyway, i've figured out a workaround so i'm not going to break my head over this one. thanks for all the advice!
Yathosho is offline   Reply With Quote
Old 3rd October 2011, 20:06   #15
{_trueparuex^}
Senior Member
 
{_trueparuex^}'s Avatar
 
Join Date: Dec 2005
Location: Glow
Posts: 285
I think you have a heap corruption issue here. The crash.log shows it crashes in ntdll.dll with memory access violation which I think is probably result of heap corruption. If this is the case you probably also get crashes with exception code 0xc0000374 (STATUS_HEAP_CORRUPTION). And the cause for heap corruption would be most likely a third party plug-in.

PaR

The guy with the ridiculous username. Thou shall call him PaR instead.
Visit My Website
{_trueparuex^} is offline   Reply With Quote
Old 3rd October 2011, 22:09   #16
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
Quote:
Originally Posted by {_trueparuex^} View Post
I think you have a heap corruption issue here. The crash.log shows it crashes in ntdll.dll with memory access violation which I think is probably result of heap corruption. If this is the case you probably also get crashes with exception code 0xc0000374 (STATUS_HEAP_CORRUPTION). And the cause for heap corruption would be most likely a third party plug-in.

PaR
hmm, so it's probably TextReplace as i've assumed before. i don't want to go back, as this plugin performs MUCH better than any functions or macros i've used before. i tried contacting instructor before to ask if he plans a unicode build, but i never heard from him since. so if plugin causes the crach (i don't want to blame the plugin, but i'm pretty sure it's causing this) it's probably never going to get fixed.
Yathosho is offline   Reply With Quote
Old 5th October 2011, 13:06   #17
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
i commented out the two plugins in question each at a time (TextReplace and Locate) and it appears that either the locate plugin is buggy or my code using it produces the bug (will look into it!) in either case, the installer didn't crash once in 2,500 test runs.

the only let down is this: what happens if it's to blame on the plugin. it appears it's no longer maintained by the author
Yathosho is offline   Reply With Quote
Old 5th October 2011, 13:18   #18
DrO
 
Join Date: Sep 2003
Posts: 27,873
Quote:
Originally Posted by Yathosho View Post
the only let down is this: what happens if it's to blame on the plugin. it appears it's no longer maintained by the author
as the source is provided, you'd need to find someone to update / fix it for you or learn how to do it

-daz
DrO is offline   Reply With Quote
Old 5th October 2011, 13:36   #19
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,363
Quote:
Originally Posted by DrO View Post
as the source is provided, you'd need to find someone to update / fix it for you or learn how to do it
you mean as a warm up for my go at avs 3.0?
Yathosho is offline   Reply With Quote
Old 5th October 2011, 13:37   #20
DrO
 
Join Date: Sep 2003
Posts: 27,873
something like that though i'd prefer a milkdrop 3 which supports avs presets

-daz
DrO is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump