Operating System - Linux
1751972 Members
5144 Online
108784 Solutions
New Discussion юеВ

-mt and -lpthread on HP-UX 11.11

 
SOLVED
Go to solution
Jim Gallagher
Occasional Advisor

-mt and -lpthread on HP-UX 11.11

Hi,

Can anyone explain this behavior? My first link uses -mt and +n without -lpthread, but it crashes (aCC runtime: Error 22 from shl_findsym(/usr/lib/libCsup_v2.2,_shlInit) ). My second link explicitly adds -lpthread, and it works. Same shell, same SHLIB_PATH, etc. Is this a bug, or am I missing something?

Thanks,

Jim Gallagher

First link:
/opt/aCC/bin/aCC -AA -mt -Wl,+n,+s,+gst,+gstsize,40387,+vshlibunsats,+vallcompatwarnings,-v -L/opt/mda_pdm/tceng101/lib -L/opt/mda_pdm/tceng101/lib/oracle -L/usr/lib -L/opt/mda_pdm/tceng101/fms/lib -L/usr/lib FMgrMain.o iman_tlogin.o report_item_acls.o FMgrMainUtils.o FMAPI_S.o FMgrAPI_S.a SQL/FMgrSQLAPI.a /users/Common/FMAPI/v10_00jim/FM_BOTH.a /users/Common/v02_12/Server.a /users/Common/v02_12/Global.a -lae -laie -laiwebservice -lappr -larchive -lbackup -lbmf -lbom -lcae -lcfm -lcollabctx -lcxpom -ldmi -lecm -leint -leintstub -lepm -lfclasses -lform -lgdis -lgrm -lics -lict -licudata32 -licui -licuuc32 -liman -limancore -limantrushape -linternal_exits -linternal_server_exits -litk -llov -lme -lmechatronics -lmgc -lobjio -love -lpcl51 -lpie -lplmxml51 -lplmxmlBusiness51 -lplmxmlClassification51 -lplmxmlDelta51 -lplmxmlMPM51 -lplmxmlMechatronics51 -lplmxmlTcEng51 -lproperty -lps -lpublication -lqry -lrdv -lres -lrwr -lsa -lsml -lss -lsub_mgr -ltceng_utils -ltcengcoreext -ltextsrv -lugmgr_im -lusage -lusagewc -luser_exits -lvis -lvispublish -lxalan -lxpk51 -larm -lxerces -lpom -luglm -lsyss -lugmath -L/opt/mda_pdm/tceng101/lib -lFPLibrary32 -lPAI_module32 -lclntsh -lm -lcl -ldld -lc -lnsl -lxti -lrt -o /tmp/FMgrMain

/usr/ccs/bin/ld -o /tmp/FMgrMain /opt/langtools/lib/crt0.o -u___exit -umain -L/opt/aCC/lib /opt/aCC/lib/cpprt0.o +n +s +gst +gstsize 40387 +vshlibunsats +vallcompatwarnings -v -L /opt/mda_pdm/tceng101/lib -L /opt/mda_pdm/tceng101/lib/oracle -L /usr/lib -L /opt/mda_pdm/tceng101/fms/lib -L /usr/lib FMgrMain.o iman_tlogin.o report_item_acls.o FMgrMainUtils.o FMAPI_S.o FMgrAPI_S.a SQL/FMgrSQLAPI.a /users/Common/FMAPI/v10_00jim/FM_BOTH.a /users/Common/v02_12/Server.a /users/Common/v02_12/Global.a -lae -laie -laiwebservice -lappr -larchive -lbackup -lbmf -lbom -lcae -lcfm -lcollabctx -lcxpom -ldmi -lecm -leint -leintstub -lepm -lfclasses -lform -lgdis -lgrm -lics -lict -licudata32 -licui -licuuc32 -liman -limancore -limantrushape -linternal_exits -linternal_server_exits -litk -llov -lme -lmechatronics -lmgc -lobjio -love -lpcl51 -lpie -lplmxml51 -lplmxmlBusiness51 -lplmxmlClassification51 -lplmxmlDelta51 -lplmxmlMPM51 -lplmxmlMechatronics51 -lplmxmlTcEng51 -lproperty -lps -lpublication -lqry -lrdv -lres -lrwr -lsa -lsml -lss -lsub_mgr -ltceng_utils -ltcengcoreext -ltextsrv -lugmgr_im -lusage -lusagewc -luser_exits -lvis -lvispublish -lxalan -lxpk51 -larm -lxerces -lpom -luglm -lsyss -lugmath -L /opt/mda_pdm/tceng101/lib -lFPLibrary32 -lPAI_module32 -lclntsh -lm -lcl -ldld -lc -lnsl -lxti -lrt -lstd_v2 -lCsup_v2 -lpthread -lm -lcl -lc /usr/lib/libdld.sl

--------------------------------------------------------
Second link:
/opt/aCC/bin/aCC -AA -mt -Wl,+n,+s,+gst,+gstsize,40387,+vshlibunsats,+vallcompatwarnings,-v -L/opt/mda_pdm/tceng101/lib -L/opt/mda_pdm/tceng101/lib/oracle -L/usr/lib -L/opt/mda_pdm/tceng101/fms/lib -L/usr/lib FMgrMain.o iman_tlogin.o report_item_acls.o FMgrMainUtils.o FMAPI_S.o FMgrAPI_S.a SQL/FMgrSQLAPI.a /users/Common/FMAPI/v10_00jim/FM_BOTH.a /users/Common/v02_12/Server.a /users/Common/v02_12/Global.a -lpthread -lae -laie -laiwebservice -lappr -larchive -lbackup -lbmf -lbom -lcae -lcfm -lcollabctx -lcxpom -ldmi -lecm -leint -leintstub -lepm -lfclasses -lform -lgdis -lgrm -lics -lict -licudata32 -licui -licuuc32 -liman -limancore -limantrushape -linternal_exits -linternal_server_exits -litk -llov -lme -lmechatronics -lmgc -lobjio -love -lpcl51 -lpie -lplmxml51 -lplmxmlBusiness51 -lplmxmlClassification51 -lplmxmlDelta51 -lplmxmlMPM51 -lplmxmlMechatronics51 -lplmxmlTcEng51 -lproperty -lps -lpublication -lqry -lrdv -lres -lrwr -lsa -lsml -lss -lsub_mgr -ltceng_utils -ltcengcoreext -ltextsrv -lugmgr_im -lusage -lusagewc -luser_exits -lvis -lvispublish -lxalan -lxpk51 -larm -lxerces -lpom -luglm -lsyss -lugmath -L/opt/mda_pdm/tceng101/lib -lFPLibrary32 -lPAI_module32 -lclntsh -lm -lcl -ldld -lc -lnsl -lxti -lrt -o /tmp/FMgrMain

/usr/ccs/bin/ld -o /tmp/FMgrMain /opt/langtools/lib/crt0.o -u___exit -umain -L/opt/aCC/lib /opt/aCC/lib/cpprt0.o +n +s +gst +gstsize 40387 +vshlibunsats +vallcompatwarnings -v -L /opt/mda_pdm/tceng101/lib -L /opt/mda_pdm/tceng101/lib/oracle -L /usr/lib -L /opt/mda_pdm/tceng101/fms/lib -L /usr/lib FMgrMain.o iman_tlogin.o report_item_acls.o FMgrMainUtils.o FMAPI_S.o FMgrAPI_S.a SQL/FMgrSQLAPI.a /users/Common/FMAPI/v10_00jim/FM_BOTH.a /users/Common/v02_12/Server.a /users/Common/v02_12/Global.a -lpthread -lae -laie -laiwebservice -lappr -larchive -lbackup -lbmf -lbom -lcae -lcfm -lcollabctx -lcxpom -ldmi -lecm -leint -leintstub -lepm -lfclasses -lform -lgdis -lgrm -lics -lict -licudata32 -licui -licuuc32 -liman -limancore -limantrushape -linternal_exits -linternal_server_exits -litk -llov -lme -lmechatronics -lmgc -lobjio -love -lpcl51 -lpie -lplmxml51 -lplmxmlBusiness51 -lplmxmlClassification51 -lplmxmlDelta51 -lplmxmlMPM51 -lplmxmlMechatronics51 -lplmxmlTcEng51 -lproperty -lps -lpublication -lqry -lrdv -lres -lrwr -lsa -lsml -lss -lsub_mgr -ltceng_utils -ltcengcoreext -ltextsrv -lugmgr_im -lusage -lusagewc -luser_exits -lvis -lvispublish -lxalan -lxpk51 -larm -lxerces -lpom -luglm -lsyss -lugmath -L /opt/mda_pdm/tceng101/lib -lFPLibrary32 -lPAI_module32 -lclntsh -lm -lcl -ldld -lc -lnsl -lxti -lrt -lstd_v2 -lCsup_v2 -lpthread -lm -lcl -lc /usr/lib/libdld.sl
9 REPLIES 9
Steven E. Protter
Exalted Contributor

Re: -mt and -lpthread on HP-UX 11.11

Shalom,

If all other factors are equal, look for a bug either in aCC or your code, or a patch thats not on the non-working system.

Another possbility is one of the libraries it needs has become corrupt due to a file delete or a disk problem of some unknown factor.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Dennis Handly
Acclaimed Contributor
Solution

Re: -mt and -lpthread on HP-UX 11.11

I'm not sure why adding -lpthread twice makes it work.

You should remove "-lm -lcl -ldld -lc" from your link line, since these are added by default.

>but it crashes (aCC runtime: Error 22 from shl_findsym(/usr/lib/libCsup_v2.2,_shlInit)

Is there any more info?
EINVAL 22 /* Invalid argument

Rats, this rings a bell!
Something about Oracle? having an evil stub for one of the pthread functions! That would explain why adding that -lpthread sooner fixed it.

http://h21007.www2.hp.com/dspp/ml/showArchiveMessage/1,,24!05!08!0011,00.html

I suppose it could also fail if -lc was added as a dependent lib to any of your listed shlibs.

If it is the same issue, link with:
-Wl,-ypthread_mutex_init
Jim Gallagher
Occasional Advisor

Re: -mt and -lpthread on HP-UX 11.11

Dennis,

Your suggestion seems to cut to where the problem is, which I'm assuming is a bug in ld or dld. I took out the libs you suggested from the lib list; hadn't thought of that (obviously). The script that is doing the link was supplied by a vendor whose libs I'm linking against. Anyway, I removed -lpthread, along with "-lm -lcl -ldld -lc", and now it works as expected.

To answer your question about the error, there was no other info. Also, I should have noted the error occurrs while dld is fixing stuff up; main() was not even reached.

That was a very good suggestion about the potential problem with the Oracle lib, but that does not seem to be it.

Thanks,

Jim
Jim Gallagher
Occasional Advisor

Re: -mt and -lpthread on HP-UX 11.11

Here's something interesting: I took out all the implied libs from the link line. I guess aCC knows best- here's the end of the ld invocation, showing just the libs that aCC added for me:

-lm -lcl -ldld -lc -lnsl -lxti -lrt -lstd_v2 -lCsup_v2 -lpthread -lm -lcl -lc /usr/lib/libdld.sl

It repeated libm, libcl and libc after libpthread!

Dennis Handly
Acclaimed Contributor

Re: -mt and -lpthread on HP-UX 11.11

>Your suggestion seems to cut to where the problem is, which I'm assuming is a bug in ld or dld.

I seriously doubt it. I think it is an issue with a pthread stub.

To track it down you would have to set a breakpoint to see where errno gets changed to EINVAL 22.

If you are in the main thread, you could just put a hardware watch point on errno.

If in another thread, you would have to set a breakpoint on __errno and finish then see if a store or load.

Or you could just use "rbreak pthread" just before your bad call to shl_findsym.

(Perhaps just the command "rbreak pthread" may tell you where the bogus stub is? You only want to see the ones in libpthread.)

You can use "catch load" to set break points before the shlibs are loaded.
Jim Gallagher
Occasional Advisor

Re: -mt and -lpthread on HP-UX 11.11

Dennis,

Using the debugger before my code even starts running is new to me. I tried what you suggested, but I think the only new information of interest was printed by gdb when I started the program without setting anything:

(gdb) r
Starting program: /code/PDM/Servers/fmapi/v10_00jim/FMgrMain
aCC runtime: Error 22 from shl_findsym(/usr/lib/libCsup_v2.2,_shlInit)

Program received signal SIGABRT, Aborted.
0x79ad55d8 in kill+0x10 () from /usr/lib/libc.2
(gdb)


Remember, my code is not even reached. In fact, I don't even use threads, but the vendor libs are linked against libpthread. Also, I don't explicitly call any of the shl_ functions.

So, you don't think it's related that aCC repeats libm, libcl and libc after libpthread on the link line?

Thanks,
Jim
Dennis Handly
Acclaimed Contributor

Re: -mt and -lpthread on HP-UX 11.11

>I tried what you suggested, but I think the only new information of interest was printed by gdb when I started the program without setting anything:

Isn't this the same?
You need to use "catch load" then the rbreak.

>you don't think it's related that aCC repeats libm, libcl and libc after libpthread on the link line?

First of all, it isn't aCC that is duplicating them, it is you or your makefile.

And as long as libc isn't before libpthread, you should be fine.

Rats, that's the problem. You can't have -lc before -lpthread:
-lm -lcl -ldld -lc -lnsl ... -lpthread -lc

This only works because of the extra:
-lpthread -lae ...
Jim Gallagher
Occasional Advisor

Re: -mt and -lpthread on HP-UX 11.11

Dennis,

>First of all, it isn't aCC that is duplicating them, it is you or your makefile.
>
You are right again.

>And as long as libc isn't before libpthread, you should be fine.
>
>Rats, that's the problem. You can't have -lc before -lpthread:
>-lm -lcl -ldld -lc -lnsl ... -lpthread -lc
>
>This only works because of the extra:
>-lpthread -lae ...
>

Once I took all the implied libs out of the script (for real this time), aCC put the implied system libs in this order on the link line:
-lstd_v2 -lCsup_v2 -lpthread -lm -lcl -lc /usr/lib/libdld.sl

Why must libpthread come before libc on the link line?

thanks,
Jim
Dennis Handly
Acclaimed Contributor

Re: -mt and -lpthread on HP-UX 11.11

>Why must libpthread come before libc on the link line?

Because libc has a bunch of pthread_* stubs. And if libc comes first, the binding order will call the stubs, rather than the real functions in libpthread.