- NSIS Discussion
- Dumplog crash
Archive: Dumplog crash
RobGrant
3rd April 2006 09:13 UTC
Dumplog crash
Hi guys
I have a function which I run after the installer finishes (or if the installer detects an error in an operation earlier, it runs this function before quitting).
It uses the DumpLog plugin - it writes the log details to a temporary file, then appends the contents of that file to the main log file (defined as a constant earlier as $logpath):
DumpLog::DumpLog "$PLUGINSDIR\log.txt"
Push $0
Push $1
Push $2
FileOpen $0 "$PLUGINSDIR\log.txt" r
FileOpen $1 "$logpath" a
FileSeek $1 "0" end
logloop:
FileRead $0 $2
IfErrors endlogloop
FileWrite $1 $2
Goto logloop
endlogloop:
FileClose $1
FileClose $0
Pop $2
Pop $1
Pop $0
The problem is it also crashes. I wondered if Dumplog has a known error or something; it won't even get as far as writing the temporary log.txt. I've triple-checked that the stack isn't being abused and causing something to fail - is there something that I don't know happening here?
To compound the problem, it doesn't always happen (e.g. on a successful install).
Thanks
Afrow UK
3rd April 2006 15:34 UTC
I'm not sure why it crashes, but it was written for increased speed over the NSIS Dump log to file function which you can try instead. The author (Instructor) checks the forums regularely. I'm sure he'd be happy if you could help him fix it.
Firstly, try putting in a MessageBox immediately after the plugin call and see if it appears.
-Stu
Instructor
3rd April 2006 15:48 UTC
DumpLog::DumpLog "$PLUGINSDIR\log.txt" .R0
MessageBox MB_OK "$$R0={$R0}"
RobGrant
3rd April 2006 15:51 UTC
Hmm yeah that's true. First I'll go over my stack usage with a fine toothcomb :)
Cheers
RobGrant
3rd April 2006 16:13 UTC
Instructor - exactly that! Miss off that variable and it bombs.
Thanks!
RobGrant
4th April 2006 15:52 UTC
There's more. Does DumpLog push the provided variable for you?
Afrow UK
4th April 2006 17:51 UTC
No need for a Pop $R0. .R0 tells the plugin to use the $R0 variable (like System plugin).
-Stu
RobGrant
5th April 2006 08:40 UTC
Heh, that'll be another reason! Do I still need to push the variable at the start, though? As in:
Push $0
DumpLog::DumpLog "$INSTDIR\log.txt" $0
MessageBox MB_OK "$0"
Pop $0
That sort of thing?
RobGrant
5th April 2006 09:39 UTC
Oh crap, should it be a . not a $ before the variable name?
E.g.
Push $0
DumpLog::DumpLog "$INSTDIR\log.txt" .0
MessageBox MB_OK "$0"
Pop $0
Afrow UK
5th April 2006 10:06 UTC
Uhm yes. If you give the plugin $0 you're passing it the contents of $0. So, if you did StrCpy $0 .0 first then it would work. .0 is specifying the variable name to use.
-Stu
RobGrant
5th April 2006 10:25 UTC
Cool thanks, I'll test that a bit later. I'm just making the DumpLog docs a bit more useful and wanted to include a link to a bit of documentation which mentions what . variable references/pointer are (e.g. .R0) but I can't find any. Anyone know of any?
Ideally some knowledge of the plugin's return vars would be good too.
Instructor
5th April 2006 11:08 UTC
From wiki:
Do not use a variable name - e.g:
$0
Use a reference to that variable name - e.g:
.0
Where is no such thing like ".0" (Readme.txt) It is personal decision to use .r0, .r1, ..., .R0, .R1, ... to make plugin call in one line. I'm recently walk away from this practice to the header use.
BTW: you can use anything else then ".r0, .r1, ..., .R0, .R1, ..." error level output will be ignored for example:
DumpLog::DumpLog "$INSTDIR\log.txt" XXX