- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- creating static object in library causing applicat...
Operating System - HP-UX
1748170
Members
4129
Online
108758
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
Discussions
Discussions
Forums
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
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
тАО05-13-2009 08:04 PM
тАО05-13-2009 08:04 PM
Here is my scenario,
1. mylib.cpp contains the code for library libfoo.sl
2. main.cpp uses the above library using dlopen.
mylib.cpp is attached and the main.cpp is like this
#include
#include
#include
typedef void (*f)(void) ;
int main()
{
void *handle = dlopen("/tmp/test/libfoo.sl",RTLD_NOW);
f cb = (f)dlsym(handle,"function");
cb();
dlclose(handle);
sleep(5);
return 0 ;
}
and the command lines are as follows
1. g++ -g -Wall -c -fPIC -D_PSTAT_64 -DPTHREAD_COMPAT_MODE -DREENTRANT -D_REENTRANT -o foo.o mylib.cpp
2. g++ -g -fPIC -shared -o libfoo.sl -lgcc_s -lstdc++ foo.o
3.gcc -g -Wl,-E main.cpp -o testexecutable
At the program exit there is a segmentation fault and the core is getting generated. Core is not telling much .
May be some flags at compile time or I am doing something really bad in code.
If I remove the static inside the void tuctuc() then everything works fine.
Any pointers will be appreciated.
Thanks,
Pramod
1. mylib.cpp contains the code for library libfoo.sl
2. main.cpp uses the above library using dlopen.
mylib.cpp is attached and the main.cpp is like this
#include
#include
#include
typedef void (*f)(void) ;
int main()
{
void *handle = dlopen("/tmp/test/libfoo.sl",RTLD_NOW);
f cb = (f)dlsym(handle,"function");
cb();
dlclose(handle);
sleep(5);
return 0 ;
}
and the command lines are as follows
1. g++ -g -Wall -c -fPIC -D_PSTAT_64 -DPTHREAD_COMPAT_MODE -DREENTRANT -D_REENTRANT -o foo.o mylib.cpp
2. g++ -g -fPIC -shared -o libfoo.sl -lgcc_s -lstdc++ foo.o
3.gcc -g -Wl,-E main.cpp -o testexecutable
At the program exit there is a segmentation fault and the core is getting generated. Core is not telling much .
May be some flags at compile time or I am doing something really bad in code.
If I remove the static inside the void tuctuc() then everything works fine.
Any pointers will be appreciated.
Thanks,
Pramod
Solved! Go to Solution.
- Tags:
- g++
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 10:18 PM
тАО05-13-2009 10:18 PM
Solution
Step 3 is broken, you must link with g++, otherwise I get unsats on IPF.
You are out of luck, g++ is broken and doesn't handle dlclose with destruction of function scope statics. (I was using 4.2.1.)
aCC6 is designed to handle it.
You are out of luck, g++ is broken and doesn't handle dlclose with destruction of function scope statics. (I was using 4.2.1.)
aCC6 is designed to handle it.
- Tags:
- dlclose
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 11:17 PM
тАО05-13-2009 11:17 PM
Re: creating static object in library causing application to crash
Thanks Denis. About this 3rd step we tried both gcc and g++ with the same result.
Ya even I figured that out that somehow g++ has some issues here but your confirmation will definetly help.
I am using gcc 4.0.1 so even moving to newer version is not going to help. Will recommend aCC to our team for next release.
Ya even I figured that out that somehow g++ has some issues here but your confirmation will definetly help.
I am using gcc 4.0.1 so even moving to newer version is not going to help. Will recommend aCC to our team for next release.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-14-2009 06:18 PM
тАО05-14-2009 06:18 PM
Re: creating static object in library causing application to crash
Our g++ expert says this is a known problem. It is due to the differences in atexit(3) between libc on HP-UX and on Linux.
- Tags:
- atexit
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.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP