Archive: Dumplog crash


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

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


DumpLog::DumpLog "$PLUGINSDIR\log.txt" .R0
MessageBox MB_OK "$$R0={$R0}"

Hmm yeah that's true. First I'll go over my stack usage with a fine toothcomb :)

Cheers


Instructor - exactly that! Miss off that variable and it bombs.

Thanks!


There's more. Does DumpLog push the provided variable for you?


No need for a Pop $R0. .R0 tells the plugin to use the $R0 variable (like System plugin).

-Stu


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?

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

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


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.


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