[comp.unix.wizards] SunOS 4.0 Dynamic Linking

souza@telesoft.UUCP (Steve Souza @eldest) (09/29/88)

Sun-Gods:

We have a job spooler application here that has suddenly broken
under SunOS 4.0.

The setup is analogous to the remote shell software in that commands
are remotely executed by a root daemon on behalf of users.  The main
difference is that the root daemon executes the job by doing a popen()
on

	". scriptfile"

(as opposed to a fork/exec, as it will someday), where "scriptfile"
contains a list of Bourne shell style variable initializations followed
by the command to execute.

The application compiles and runs without a hitch, but when "scriptfile"
hits a 4.0 executable (i.e. the user command), it barfs with the
message:

	crt0: /usr/lib/ld.so mapping failure

If a 3.x program binary is copied to the remote (4.0) machine, the
daemon has no problem executing it, so it appears to be a problem with
4.0 dynamic linking in a shell environment that is somehow different.
I've tried compiling both the daemon software and the target command with
and without the -Bstatic switch, to no avail.

Any thoughts, suggestions, or guesses?

Thanks!

Steve Souza		      ...ucsd!telesoft!souza, telesoft!souza@ucsd.edu
TELESOFT Inc., San Diego, CA  (619)457-2700 x277

souza@telesoft.UUCP (Steve Souza @eldest) (10/06/88)

The problem is solved!  Many thanks to all who responded.

    Turns out to have been a problem with the max allocable
process stack segment.  There is a call to setrlimit in our
daemon just prior to the system(3) of the sub-process.  This
call removed the limit on RLIMIT_STACK, and set it to
RLIM_INFINITY. 

    This seems to make the dynamic linker (DL) unhappy.  One
person (Greg Onufer) who had this problem reported that
increasing the swap partition size on his system fixed the
problem.  Seems the DL uses less physical memory, but more
virtual memory.  These pieces all fit together somehow, but I
don't know how without source.  I wonder if the DL doesn't
pre-allocate stack to the limit before invoking the command...

    Anyways, You can duplicate these messages on your 4.0
system by playing with the C-shell "limit" command:

	unlimit stack
	ls
	limit stack 2048
	
Here are some of the command error messages I got after creeping up
towards the system limit:

	ld.so: swap space exhausted for mmap of /usr/lib/libc.so.0.10
	ld.so: map heap error (22) for /dev/zero
	crt0: /usr/lib/ld.so mapping failure
----------------------------------------------------------------------------
Steve Souza			ucsd!telesoft!souza, telesoft!souza@ucsd.edu
TELESOFT Inc., San Diego, CA	(619)457-2700 x277

cudcv@warwick.ac.uk (Rob McMahon) (10/07/88)

In article <314@telesoft.UUCP> souza@telesoft.UUCP (Steve Souza @eldest) writes:
>We have a job spooler application here that has suddenly broken
>under SunOS 4.0.
>...
>The application compiles and runs without a hitch, but when "scriptfile"
>hits a 4.0 executable (i.e. the user command), it barfs with the
>message:
>	crt0: /usr/lib/ld.so mapping failure

This may be completely unrelated, but it's worth knowing anyway.  I had a user
the other day who got this message with every command he tried to run, pwd,
ls, printenv, whatever.  The culprit turned out to be an `unlimit' command in
his .login.  Apparently if you `unlimit stack' you are suddenly unable to
execute any dynamically linked executables.  `limit stack 2M' cured the
problem.

Rob
-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv@uk.ac.warwick             ARPA:   cudcv@warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England