[rt.cpan.org #132811] Win32: Crash a week after start

2020-06-13 Thread Shawn Laffan via RT
Sat Jun 13 23:32:46 2020: Request 132811 was acted upon.
Transaction: Correspondence added by SLAFFAN
   Queue: PAR-Packer
 Subject: Win32: Crash a week after start
   Broken in: (no value)
Severity: (no value)
   Owner: Nobody
  Requestors: ralf.neuba...@wido.bv.aok.de
  Status: open
 Ticket https://rt.cpan.org/Ticket/Display.html?id=132811 >


On Sat Jun 13 18:45:02 2020, SLAFFAN wrote:
> On Sat Jun 13 06:44:03 2020, ralf.neuba...@wido.bv.aok.de wrote:
> > Hi.
> >
> > > > FWIW, I'd be OK if the default PAR_TEMP location was in the
> > > > user's
> > > > home dir or under C:\ProgramData ($ENV{PROGRAMDATA}).  The latter
> > > > might have issues on shared machines depending on how the
> > > > unpacked
> > > > files are used, though.
> > >
> > > $ENV{APPDATA} would be better than $ENV{PROGRAMDATA}
> > >
> > > It is easy enough to add to mktmpdir.c for Windows builds, so I can
> > > work up a PR if Roderich is in favour of the idea.
> >
> > What is your concept for getting rid of old PAR_TEMP locations once
> > you get (or create) an updated version of the application or just
> > stop
> > using it? Explicit deinstallation (maybe by using a special argument
> > or variable when calling this version)? An own version of 'delete old
> > files' but with a longer timeout and using a better protocol for
> > detecting the last use and removing only whole directories? Giving
> > the
> > user better hints than cryptic directory names with cryptic files in
> > it, that he can decide which dirs to purge manually? This could be
> > implemented by description files or by a version manager.
> >
> > Explicit deinstallation could be paired with explicit installation --
> > the application only unpacks intelf into a permanent location, if you
> > explicely tell it to do so, in a way every user understands.
> >
> > Mit freundlichen Grüßen
> >
> > Ralf Neubauer
> 
> 
> Currently there is no removal of old PAR archives that I am aware of.
> Removal is left to the user or automated processes.
> 
> It could be done manually using PAR_GLOBAL_CLEAN at the cost of
> running the exe.  e.g. for some_archive.exe this could be packed into
> an uninstall.bat:
> 
> set PAR_GLOBAL_CLEAN=1
> some_archive.exe
> 
> Maybe this could be added to PAR so it does not run the exe and just
> does the cleanup, e.g.:
> 
> some_archive.exe --run-par-cleanup
> 
> It's probably conceptually simpler for the user if it is a separate
> process, though.
> 
> It would also be possible to add that logic to your own perl script so
> it can exit without doing anything, but it might be too late by the
> time that is loaded.

I've run some testing and neither approach works.  When PAR_GLOBAL_TEMP is set 
before running the exe, the archive is unpacked into a different folder named 
like temp-12345 and cleaned up on exit.  Setting it in a BEGIN block within the 
packed script appears too late to have any effect.  Presumably the environment 
is localised or some other flag is set by PAR at startup to check on exit.

It looks like a separate uninstaller is needed, although it would need to 
ensure it does not remove files from under a running process, as otherwise it 
is another example of the original reported issue.

Shawn.


[rt.cpan.org #132811] Win32: Crash a week after start

2020-06-13 Thread Shawn Laffan via RT
Sat Jun 13 18:45:02 2020: Request 132811 was acted upon.
Transaction: Correspondence added by SLAFFAN
   Queue: PAR-Packer
 Subject: Win32: Crash a week after start
   Broken in: (no value)
Severity: (no value)
   Owner: Nobody
  Requestors: ralf.neuba...@wido.bv.aok.de
  Status: open
 Ticket https://rt.cpan.org/Ticket/Display.html?id=132811 >


On Sat Jun 13 06:44:03 2020, ralf.neuba...@wido.bv.aok.de wrote:
> Hi.
> 
> > > FWIW, I'd be OK if the default PAR_TEMP location was in the user's
> > > home dir or under C:\ProgramData ($ENV{PROGRAMDATA}).  The latter
> > > might have issues on shared machines depending on how the unpacked
> > > files are used, though.
> >
> > $ENV{APPDATA} would be better than $ENV{PROGRAMDATA}
> >
> > It is easy enough to add to mktmpdir.c for Windows builds, so I can
> > work up a PR if Roderich is in favour of the idea.
> 
> What is your concept for getting rid of old PAR_TEMP locations once
> you get (or create) an updated version of the application or just stop
> using it? Explicit deinstallation (maybe by using a special argument
> or variable when calling this version)? An own version of 'delete old
> files' but with a longer timeout and using a better protocol for
> detecting the last use and removing only whole directories? Giving the
> user better hints than cryptic directory names with cryptic files in
> it, that he can decide which dirs to purge manually? This could be
> implemented by description files or by a version manager.
> 
> Explicit deinstallation could be paired with explicit installation --
> the application only unpacks intelf into a permanent location, if you
> explicely tell it to do so, in a way every user understands.
> 
> Mit freundlichen Grüßen
> 
> Ralf Neubauer


Currently there is no removal of old PAR archives that I am aware of.  Removal 
is left to the user or automated processes.  

It could be done manually using PAR_GLOBAL_CLEAN at the cost of running the 
exe.  e.g. for some_archive.exe this could be packed into an uninstall.bat:

  set PAR_GLOBAL_CLEAN=1
  some_archive.exe

Maybe this could be added to PAR so it does not run the exe and just does the 
cleanup, e.g.:

some_archive.exe --run-par-cleanup

It's probably conceptually simpler for the user if it is a separate process, 
though.  

It would also be possible to add that logic to your own perl script so it can 
exit without doing anything, but it might be too late by the time that is 
loaded.


[rt.cpan.org #132811] Win32: Crash a week after start

2020-06-13 Thread Shawn Laffan via RT
Sat Jun 13 02:59:53 2020: Request 132811 was acted upon.
Transaction: Correspondence added by SLAFFAN
   Queue: PAR-Packer
 Subject: Win32: Crash a week after start
   Broken in: (no value)
Severity: (no value)
   Owner: Nobody
  Requestors: ralf.neuba...@wido.bv.aok.de
  Status: open
 Ticket https://rt.cpan.org/Ticket/Display.html?id=132811 >


On Fri Jun 12 22:04:55 2020, SLAFFAN wrote:
> On Fri Jun 12 21:35:12 2020, ralf.neuba...@wido.bv.aok.de wrote:
> > Hi.
> >
> > > This is related to
> > > https://rt.cpan.org/Public/Bug/Display.html?id=101800
> >
> > Yes and no. _CANARY_.txt exists and the directory will be repopulated
> > on the next start of the program, so there is no problem except
> > having
> > to unpack the files again between runs of the program. My problem on
> > the other hand is, that I start the program and the files are deleted
> > while it is running. My crude protection scheme (locking all of the
> > files -- 3500 files in my case, which only works with Windows file
> > handles since Perl only gets the 2048 file handles implemented by the
> > Windows libc) only protects the files while the program is running,
> > so
> > _CANARY_.txt is still needed (and there is a short time window at the
> > start of the program, inbetween starting the unpacking and locking
> > the
> > files, where files could still vanish if you are unlucky enough to
> > have cleanmgr.exe run at exactly the same time.
> >
> > Using a non-temp-directory would solve both problems but carries some
> > problems on its own, see original message. Declaring %TEMP% to be a
> > non-temp directory sounds strange. Raising the existence interval
> > only
> > makes it less bad, but doesn't solve it. Also you have to have
> > administrator privilege for both.
> >
> > I also thought about keeping the files fresh by manipulating their
> > timestamps, that also doesn't really solve it, but reflects the truth
> > that the files have been used very recently. The would be easy but
> > time-consuming on startup (and make _CANARY_.txt obsolete). To solve
> > the runtime problems you would have to spawn a parallel job to keep
> > the files fresh every couple of hours.
> >
> > In essence, the reason is the same, but I don't see a simultaneous
> > solution for both aspects that doesn't require user oder
> > administrator
> > input.
> >
> > Mit freundlichen Grüßen
> >
> > Ralf
> 
> Yes, the canary file only helps in cases where files are deleted
> between program runs or where files only need to be read at startup.
> 
> The regular temp file cleanup will also impact all users in that the
> PAR archive needs to be unpacked each time it is cleaned up, causing a
> slow user experience for large archives at startup.
> 
> FWIW, I'd be OK if the default PAR_TEMP location was in the user's
> home dir or under C:\ProgramData ($ENV{PROGRAMDATA}).  The latter
> might have issues on shared machines depending on how the unpacked
> files are used, though.
> 
> Shawn.

$ENV{APPDATA} would be better than $ENV{PROGRAMDATA}

It is easy enough to add to mktmpdir.c for Windows builds, so I can work up a 
PR if Roderich is in favour of the idea.  


Re: [rt.cpan.org #132811] Win32: Crash a week after start

2020-06-13 Thread Shawn Laffan
 That approach is probably a good workaround for now.

If one wants to keep everything in a single par file then the needed files
could be packed as a zip file that is itself packed into the PAR exe file.
This can then be extracted to some other folder outside the temp dir when
the exe is first run.

Somewhere like $ENV{APPDATA}/your-app would work.

Shawn.


On Sat, 13 Jun 2020 at 15:41, Oliver Betz  wrote:

> Ralf.Neubauer wrote:
>
> > Is there a better way?
>
> did you consider to use pp to crete the set of required files, but *not*
> at runtime?
>
> You can then put all the required files to a safe directory, optionally
> even write protected for ordinary users to avoid unexpected modification.
>
> I made a simple launcher replacing perl.exe if your users don't want to
> need to invoke perl.exe yourapplication.pl
>
> I remember there is even an "unpacker" from another user to extract all
> the needed files from a pp created exe archive.
>
> Oliver
>