[R-pkg-devel] Incomprehensible warning while checking

Ivan Krylov |kry|ov @end|ng |rom d|@root@org
Sat Jun 29 12:28:07 CEST 2024


В Fri, 28 Jun 2024 17:57:13 -0400
Iris Simmons <ikwsimmo using gmail.com> пишет:

> * checking whether the namespace can be unloaded cleanly ... WARNING
> ---- unloading

Here's what the check does (in a separate process):

invisible(suppressMessages(loadNamespace("this.path")));
cat('\n---- unloading\n');
unloadNamespace("this.path")

Since the output stops at "---- unloading", the package may be crashing
somewhere in SEXP do_onUnload(...). I couldn't reproduce the crash with
this.path_2.4.0.20 (commit 301f3691e93dce95adf937387b1a7bbbed5ae15d)
you currently have available in the Git repository, but I did find
this.path_2.5.0.tar.gz in the archive subdirectory on the CRAN FTP
server, which crashes R-devel but not R-4.4.1 on Windows:

* checking whether the namespace can be unloaded cleanly ...Rterm.exe caused an Access Violation at location 00007FFCC43B2640 DEP violation at location 00007FFCC43B2640.

AddrPC           Params
00007FFCC43B2640 00007FFCB98E85D8 000001DCA1D23E60 000001DCA1D20500
00007FFCBFB758B4 000001DCA1D24AB0 0000000000000000 0000000000000000  this.path.dll!getInFrame+0x54  [C:/Users/user/THISPA~1.RCH/00_PKG~1/THIS~1.PAT/src/thispathdefn.c @ 120]
   118:         Rf_error(_("object '%s' not found"), EncodeChar(PRINTNAME(sym)));
   119:     if (TYPEOF(value) == PROMSXP) {
>  120:         if (ptr_PRVALUE(value) == R_UnboundValue) {
   121:             Rf_protect(value);
   122:             value = Rf_eval(value, R_EmptyEnv);
00007FFCBFB579B1 000001DCA1D04110 0000006D595FCA78 000001DC9D42BFC8  this.path.dll!do_onUnload+0x2c1  [C:/Users/user/THISPA~1.RCH/00_PKG~1/THIS~1.PAT/src/ns-hooks.c @ 1011]
  1009:         R_ProtectWithIndex(expr = Rf_cons(libpath, R_NilValue), &indx);
  1010:         R_Reprotect(expr = Rf_cons(Rf_mkString("this.path"), expr), indx);
> 1011:         R_Reprotect(expr = Rf_lcons(getFromBase(Rf_install("library.dynam.unload")), expr), indx);
  1012:         R_Reprotect(expr = Rf_cons(expr, R_NilValue), indx);
  1013:         R_Reprotect(expr = Rf_lcons(getFromBase(on_exitSymbol), expr), indx);
00007FFCB7525CCF 000001DCA02A6C70 000001DC9D452A78 000001DC9D42BF58  R.dll!do_External+0x28f  [C:/R/R-svn/src/main/dotcode.c @ 573]

I don't understand why a call to
on.exit(library.dynam.unload("this.path", libpath)) has to be
constructed this way and not directly in R/ns-hooks.R (something to do
with R-2.15.0 compatibility? that's very impressive, by the way, as are
the rest of the package internals), but I hope that this helps you
diagnose the problem further.

One other thing I also found was a small memory leak: the memory
allocated in path_join -> unix_path_join -> src/pathjoin.c:461 is not
released. (Looks like it's the same in windows_path_join.) I'd use
R_alloc if I could.

-- 
Best regards,
Ivan



More information about the R-package-devel mailing list