Transitive dlopen with the same name on macOS loads the previous one - dlopen

I have two shared libraries (libMain.dylib) in separate directories, each of which loads another shared library (libutils.dylib) in its own directory:
/dirA/{libMain.dylib, libutils.dylib}
/dirB/{libMain.dylib, libutils.dylib}
In my code, I load /dirA/libMain.dylib, unload it, and then attempt to load /dirB/libMain.dylib:
void *h;
h = dlopen("/dirA/libMain.dylib", RTLD_LAZY | RTLD_LOCAL);
dlclose(h);
h = dlopen("/dirB/libMain.dylib", RTLD_LAZY | RTLD_LOCAL);
The problem is that the second library tries to load /dirA/libutils.dylib, not the one in its directory /dirB. This is confirmed by running my app with DYLD_PRINT_SEARCHING=1:
--- loading /dirA/libMain.dylib
...
dyld[52079]: find path "#rpath/libutils.dylib"
dyld[52079]: LC_RPATH '#loader_path' from '/dirA/libMain.dylib'
dyld[52079]: possible path(#path expansion): "/dirA/libutils.dylib"
dyld[52079]: found: dylib-from-disk: "/dirA/libutils.dylib"
...
--- loading /dirB/libMain.dylib
...
dyld[52079]: find path "#rpath/libutils.dylib"
dyld[52079]: found: already-loaded-by-rpath: /dirA/libutils.dylib
Note that libMain.dylib loads libutils.dylib the following way:
dlopen("#loader_path/libutils.dylib", RTLD_LAZY | RTLD_LOCAL)
This is how I deal with this problem on Linux and Windows:
on Linux, call dlopen with the proper libutils.so myself beforehand OR use dlmopen with LM_ID_NEWLM
on Windows, call SetDllDirectory with the proper directory before opening Main.dll
None of this works (I've tried) or is applicable (to my knowledge) on macOS. Moreover, RTLD_NOW/LAZY and RTLD_LOCAL/GLOBAL has no effect on this problem. Renaming libMain.dylib to something else prior loading it has no effect either.
Is there anything that can be done?

Related

Problem downloading package from git actions, results in mangled URL

In our git actions output for testing our custom R package (hosted on github), we're experiencing an error during execution:
Error in utils::download.file(url, path, method = method, quiet = quiet, :
cannot open URL 'https://api.github.com/repos/***/CirceR/contents/DESCRIPTION?ref=HEAD'
Calls: saveRDS ... github_DESCRIPTION -> download -> base_download -> base_download_headers
Execution halted
Error: Process completed with exit code 1.
The main repo is here: https://github.com/OHDSI/CohortGenerator
The github actions report is here: https://github.com/OHDSI/CohortGenerator/runs/3294257207?check_suite_focus=true
The referenced package CirceR is found here: https://github.com/ohdsi/circer
Our main question is: is it normal for the requested URL for the DESCRITPION file to be masked with the *** as in: cannot open URL 'https://api.github.com/repos/***/CirceR/contents/DESCRIPTION?ref=HEAD'
If we change the *** to the actual organization OHDSI for this URL the request works, so is it possible the URL is being mangled?
We've tested loading each individual package locally and this error doesn't occur, so we think it's localized to github actions.
I believe the output is trying to shorten the string so you can see how it starts, and how it ends, but not the middle...for readability purposes. My issue was I wanted the entire contents of the string (other errors in 'shorter' repository names gives the full URL). So, I believe this truncation is by design.
To solve the underlying issue, I had to specify a GIT_PAT to use to invoke the API and that cleared out the error I was getting.

differences between get_directory_client and get_subdirectory_client for azure file share

Azure file share Python SDKs have two similar methods get_directory_client and get_subdirectory_client. It seems both are interacting with directories. But do we need two methods to perform the same task?
get_directory_client is to get the root directory, and get_subdirectory_client is to get the subdirectories of the current directory.
As you can see from the document, you must get the ShareClient object first. At this time, you can only call get_directory_client to get the root directory, and then you will get the ShareDirectoryClient object. At this time, if you want to get the subdirectory , You can only call the get_subdirectory_client method.
You can also refer to the description of the file share client to understand the difference:
==========================update======================
connection_string = "<your-connection-string>"
service = ShareServiceClient.from_connection_string(conn_str=connection_string)
share = service.get_share_client("<your-file-share-name>")
my_files = []
for item in share.list_directories_and_files():
my_files.append(item)
if item["is_directory"]:
for item2 in share.get_directory_client(item["name"]).list_directories_and_files():
my_files.append(item)
for item3 in share.get_directory_client(item["name"]).get_subdirectory_client(item2["name"]).list_directories_and_files():
my_files.append(item3)
else:
my_files.append(item)
print(my_files)
You can refer to this official documentation.
Honestly, I find it a bit confusing having to deal with two different methods to do "the same thing". I prefer to instantiate the directory client via the from_connection_string method.
For more information on how to list files from a FileShare, take a look at the following post: "Azure File Share - Recursive Directory Search like os.walk". The approach I reported allows to list files recursively, walking through the directories.

STM32 StdPeriph library USART example

I downloaded Stdperiph library and i want to make USART example run on STM32F4 - Discovery. I chose STM32F40_41xxx workplace, added stm32f324x7i.c file and compiled without any errors.
Issue is that I cant receive expected message in my terminal (using Hercules), also when I check RxBuffer it is receiving some bytes but not that I sent.
I checked baudrate, wordlength, parity several times. Do you have any idea what could I do wrong?
USART conf:
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_2;
USART_InitStructure.USART_Parity = USART_Parity_Odd;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
STM_EVAL_COMInit(COM1, &USART_InitStructure);
Thank you.
First of all if you want to use hihg level abstraction libraries stop using obsolete SPL and start using HAL. Install the Cube. Generate the code - import into your favorite IDE and compile. Should work.
Your code does not show anything as USART clock may be net enabled as well as GPIOs. GPIOs may be configured wrong way. You system and peripheral clock may have wrong frequency. There are many more potential problems.

unable to run activeX control in IE

Im trying to embed some application in IE by creating activeX control. I've got xyz.dll. Normally if I register this dll through command prompt(batch file), the embedding is successful. But if i use the cab file methodolgy, only the first snapshot of application loads in IE(embedded application fails to run) inspite of the fact that registration of dll is taking place.
xyz.cab file contains, xyz.dll and xyz.inf.
The xyz.inf is as following:
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Add.Code]
xyz.dll=xyz.dll
[Deployment]
InstallScope=user|machine
[xyz.dll]
file-win32-x86=thiscab
clsid={HJI9D4D39-K9F5-489B-8032-CCHB1B189J10}
FileVersion=1,0,0,0
RegisterServer=yes
RedirectToHKCU=yes
HRESULT IEInstallScope(LPDWORD pwdScope);
I'm making cab file through makecab.exe and im signing cab file too with signtool.exe and makecert technique and finally the excerpt from the html is as following:
...
CLASSID="clsid:HJI9D4D39-K9F5-489B-8032-CCHB1B189J10"
CODEBASE="C:\xyz\13\plugins\ie\xyz.cab#Version="1,0,0,0"
...
So i dont know why Im facing this problem.The reason may be because thers something Im mistaking inside inf file or I dont know the exact usage of "HRESULT IEInstallScope(LPDWORD pwdScope); "or is it associated with dll????
please help me!!!!!!
EDIT:::well this worked out for me, but i still dont know why registerserver=yes fails to embedd activex perfectly::
new inf file is as following:
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Add.Code]
xyz.dll=xyz.dll
[Deployment]
InstallScope=user|machine
[Setup Hooks]
xcxc=xcxc
xcxc1=xcxc1
[xyz.dll]
file-win32-x86=thiscab
clsid={HJI9D4D39-K9F5-489B-8032-CCHB1B189J10}
FileVersion=13,0,0,0
RegisterServer=yes
RedirectToHKCU=yes
HRESULT IEInstallScope(LPDWORD pwdScope);
[regDll]
hook=xcxc
[xcxc]
run=C:\Windows\System32\regsvr32.exe "C:\xyz\13\plugins\ie\xyz.dll"
[abcDll]
hook=xcxc1
[xcxc1]
run=C:\Windows\syswow64\regsvr32.exe /u /s "C:\xyz\13\plugins\ie\xyz.dll"

The requested resource () is not available. - iframe pdf

Inside of iframe I get the error message :
HTTP Status 404 -
type Status report
message
descriptionThe requested resource () is not available.
GlassFish Server Open Source Edition 3.1.2.2
I have placed a pdf in the folder resources/pdf/1.pdf and it does not matter where I place this file, I get this error, what have I done wrong or forgotten to do, it is a page that just shows the user an instruction manual.
<iframe src="/resources/pdf/1.pdf"></iframe>
|
| Gui
| `---- submittedPDF.xhtml
|
|
|resources
`pdf
`1.pdf
Heres a print screen of the structure
http://i1081.photobucket.com/albums/j348/west-wot/directory_zpsf8b3b5aa.png
Update your code in the submittedPDF.xhtml to
<iframe src="../resources/pdf/1.pdf"></iframe>
.. and . have following meanings in file paths:
.. means up one directory and . means current directory.
<iframe src="/resources/pdf/1.pdf"></iframe>
The leading slash brings you to the domain root, skipping the context path.
You need to include the context path:
<iframe src="#{request.contextPath}/resources/pdf/1.pdf"></iframe>
Or, as it's apparently been placed in /resources folder, use the implicit #{resource} map:
<iframe src="#{resource['pdf/1.pdf']}"></iframe>
Either way, it'll autogenerate the proper domain-relative URL, including the context path.