negrutiu / nsis-nscurl

NSIS plugin with advanced HTTP/S capabilities
BSD 3-Clause "New" or "Revised" License
26 stars 7 forks source link

.dll file stays loaded/doesn't get deleted when installer closes #15

Open el0401 opened 2 months ago

el0401 commented 2 months ago

I use the NScurl plugin to download a file like this:

NScurl::http GET "$5" "$6" /SILENT /CANCEL /INSIST /TIMEOUT 30s /CACERT "${TEMP_DIR}\cacert.pem" /RETURN "@ERRORTYPE@:@ERRORCODE@" /END

Everything works fine, but the plugin remains in $PLUGINSDIR even after the installer is finished. All the other files from that folder get removed correctly.

I also tried deleting the folder by myself using

SetOutPath $TEMP
RMDir /r $PLUGINSDIR

on the .onGUIEnd function, but it doesn't work as well. The only thing that works is setting the /REBOOTOK flag and then rebooting to completely remove it, which is fine, though I'd like to remove it without a reboot, if possible.

negrutiu commented 2 months ago

This is a known issue and there is no working solution for it yet.

The problem lies in the underlying libcurl framework. I was forced to block NScurl.dll from unloading (and thus creating this issue) because otherwise libcurl might end up crashing. The crash was actually confirmed on older platforms like Windows XP, Vista, etc.

As mentioned in the curl_global_cleanup documentation, libcurl should not be used in modules that unload dynamically (like NScurl.dll does). So, to prevent potential crashes I came up with this "hack" a while ago...

Let's keep this issue opened and keep looking for a fix... Thanks for reporting!

el0401 commented 2 months ago

Thank you for answering! I'm somewhat relieved because i thought something isn't working right with my installer. It definitely makes sense the way you handled this, I'll be looking into this as well, maybe we'll come up with a solution for this at some point.