caught segfault error 'invalid permissions', fail at makeLazyLoading from package install

I encounter an installation error while install.packages("restfulr") on Posit Workbench. It is hosted on RedHat 8 server and installed R 4.4.0 and R 4.2.1. The error posted below:

> install.packages("restfulr")
Installing package into ‘/staging/home/csu03/R/library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/restfulr_0.0.15.tar.gz'
Content type 'application/x-gzip' length 15033 bytes (14 KB)
==================================================
downloaded 14 KB

* installing *source* package ‘restfulr’ ...
** package ‘restfulr’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -I"/opt/R/4.2.1/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2  -c init.c -o init.o
gcc -I"/opt/R/4.2.1/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2  -c raggedListToDF.c -o raggedListToDF.o
gcc -shared -L/opt/R/4.2.1/lib/R/lib -L/usr/local/lib -o restfulr.so init.o raggedListToDF.o -L/opt/R/4.2.1/lib/R/lib -lR
installing to /staging/home/csu03/R/library/4.2/00LOCK-restfulr/00new/restfulr/libs
** R
** inst
** byte-compile and prepare package for lazy loading
sh: line 1: 764726 Segmentation fault      R_TESTS= '/opt/R/4.2.1/lib/R/bin/R' --no-save --no-restore --no-echo 2>&1 < '/tmp/RtmpPGKvGt/filebaac57270b9eb'

 *** caught segfault ***
address 0x7f1199f29090, cause 'invalid permissions'

Traceback:
 1: fun(libname, pkgname)
 2: doTryCatch(return(expr), name, parentenv, handler)
 3: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 4: tryCatchList(expr, classes, parentenv, handlers)
 5: tryCatch(fun(libname, pkgname), error = identity)
 6: runHook(".onLoad", env, package.lib, package)
 7: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
 8: asNamespace(ns)
 9: namespaceImportFrom(ns, loadNamespace(j <- i[[1L]], c(lib.loc,     .libPaths()), versionCheck = vI[[j]]), i[[2L]], from = package)
10: loadNamespace(package = package, lib.loc = lib.loc, keep.source = keep.source,     keep.parse.data = keep.parse.data, partial = TRUE)
11: withCallingHandlers(expr, packageStartupMessage = function(c) tryInvokeRestart("muffleMessage"))
12: suppressPackageStartupMessages(loadNamespace(package = package,     lib.loc = lib.loc, keep.source = keep.source, keep.parse.data = keep.parse.data,     partial = TRUE))
13: code2LazyLoadDB(package, lib.loc = lib.loc, keep.source = keep.source,     keep.parse.data = keep.parse.data, compress = compress, set.install.dir = set.install.dir)
14: tools:::makeLazyLoading("restfulr", "/staging/home/csu03/R/library/4.2/00LOCK-restfulr/00new",     keep.source = FALSE, keep.parse.data = FALSE, set.install.dir = "/staging/home/csu03/R/library/4.2/restfulr")
An irrecoverable exception occurred. R is aborting now ...
ERROR: lazy loading failed for package ‘restfulr’
* removing ‘/staging/home/csu03/R/library/4.2/restfulr’
* restoring previous ‘/staging/home/csu03/R/library/4.2/restfulr’
Warning in install.packages :
  installation of package ‘restfulr’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/RtmpDGJBXZ/downloaded_packages’

I have written permission to the used lib location (/staging/home/csu03/R/library/4.2/). The issue is not specific to {restfulr} installation or R version. For some packages (but not all), it result in the same error. I also tested on R 4.4.0, the same error occur.

I want to know what the error means and what i can do to fix it.

This seems like a broken toolchain to me. Does it happen to other packages that require compilation? Can you load all dependencies of this package? Are you using CPU emulation? (E.g. are you using Docker with a different platform?)

Yes, for the packages that require compilations the installation fail. I tried XML (which restfulr was dependent on) with compilation (from CRAN repo) and without compilation (from rstudio package manager for centos 8). The formal resulted in the same error but the later one was installed without problem. All other dependency for the package can be loaded appropriately.

With your hint, i located the issue. it is due to the env setting ("CPATH") on my user .Renviron. I pointed it to conda env include/. Thank you so much for the suggestions!