HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Use of dlsym() function hangs process
Operating System - HP-UX
1830845
Members
2563
Online
110017
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2001 04:16 AM
09-17-2001 04:16 AM
Use of dlsym() function hangs process
Hi,
we're working on porting an application from Solaris to HP-UX. We use shared object libraries, and when we try getting an address of a function in a .sl file, dlsym simply hangs the process and it starts using a full CPU.
Here is a code snippet:
struct stat statbuf;
if (stat(modulename,&statbuf) == -1)
{
continue;
}
if ((statbuf.st_mode&S_IFMT) != S_IFREG)
{
continue;
}
tmp.module = dlopen(modulename, RTLD_NOW);
if (!tmp.module)
{
continue;
}
/* THIS CALL HANGS */
tmp.descriptor = reinterpret_cast(
dlsym(tmp.module, "networking_descriptor"));
Our compiler flags are the following:
aCC -c +DA2.0 -Aa +Z +w +W495 +W887 +W818 +W819 +W392 +W749 +W655 +W361 +W684 +W431 +O0 +inline_level 0 -g1 +objdebug -I/usr/local/ims_tornado_depend/stlport -DUSING_NAMESPACE_STD='using namespace std' -DSTLport -I/usr/local/ims_tornado_depend/include -D_REENTRANT -I../lib -I../lib/hpux/acc -I../lib/hpux -I./Comm -I./Idapi -I./Networking -DSHLIB_EXT=\".sl\" -D_HPUX_SOURCE -D_REENTRANT -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 -/lib/hpux/acc -c Networking.cc -o Networking.o
System info:
$ uname -a
HP-UX n4000 B.11.11 U 9000/800 688379372 unlimited-user license
Any input will be greatly appreciated.
Brian
we're working on porting an application from Solaris to HP-UX. We use shared object libraries, and when we try getting an address of a function in a .sl file, dlsym simply hangs the process and it starts using a full CPU.
Here is a code snippet:
struct stat statbuf;
if (stat(modulename,&statbuf) == -1)
{
continue;
}
if ((statbuf.st_mode&S_IFMT) != S_IFREG)
{
continue;
}
tmp.module = dlopen(modulename, RTLD_NOW);
if (!tmp.module)
{
continue;
}
/* THIS CALL HANGS */
tmp.descriptor = reinterpret_cast
dlsym(tmp.module, "networking_descriptor"));
Our compiler flags are the following:
aCC -c +DA2.0 -Aa +Z +w +W495 +W887 +W818 +W819 +W392 +W749 +W655 +W361 +W684 +W431 +O0 +inline_level 0 -g1 +objdebug -I/usr/local/ims_tornado_depend/stlport -DUSING_NAMESPACE_STD='using namespace std' -DSTLport -I/usr/local/ims_tornado_depend/include -D_REENTRANT -I../lib -I../lib/hpux/acc -I../lib/hpux -I./Comm -I./Idapi -I./Networking -DSHLIB_EXT=\".sl\" -D_HPUX_SOURCE -D_REENTRANT -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 -/lib/hpux/acc -c Networking.cc -o Networking.o
System info:
$ uname -a
HP-UX n4000 B.11.11 U 9000/800 688379372 unlimited-user license
Any input will be greatly appreciated.
Brian
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2001 08:18 PM
09-17-2001 08:18 PM
Re: Use of dlsym() function hangs process
Brian,
If you get into any of the if(...) continue loops, of course you would use 100% of the CPU. They will loop forever, until the variable you are testing changes.
It's not clear to me why you are using this approach. Why not load the library, which is a blocking call that will not return until the module is loaded. Once it's loaded without any error codes, you should be able to make the dlsym call, and get the information you want.
If you really want to only read the symbol information once it's available, because you want to do something else in the background,
there are much better ways to do this. Selecting on an interrupt might be a way to block until the file is loaded.
But the time involved should be very short anyway.
Maybe if you provide some information on what you are trying to accomplish, we can provide a better recommendation on how to do it.
--Carl
If you get into any of the if(...) continue loops, of course you would use 100% of the CPU. They will loop forever, until the variable you are testing changes.
It's not clear to me why you are using this approach. Why not load the library, which is a blocking call that will not return until the module is loaded. Once it's loaded without any error codes, you should be able to make the dlsym call, and get the information you want.
If you really want to only read the symbol information once it's available, because you want to do something else in the background,
there are much better ways to do this. Selecting on an interrupt might be a way to block until the file is loaded.
But the time involved should be very short anyway.
Maybe if you provide some information on what you are trying to accomplish, we can provide a better recommendation on how to do it.
--Carl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2001 11:17 PM
09-17-2001 11:17 PM
Re: Use of dlsym() function hangs process
Hi Carl,
no, the ifs won't hang because this code snippet is from a loop that loops through all files in a folder. The continue statements will cause the loop to process the next file.
I'm simply trying to load a dynamic library and get the address of a function in that library. It's 32bit code. I have seen others use a workaround and drop the dl functions and use shl_ functions instead.
Brian
no, the ifs won't hang because this code snippet is from a loop that loops through all files in a folder. The continue statements will cause the loop to process the next file.
I'm simply trying to load a dynamic library and get the address of a function in that library. It's 32bit code. I have seen others use a workaround and drop the dl functions and use shl_ functions instead.
Brian
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP