Bug 33548 - Core dump on HPUX
Summary: Core dump on HPUX
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-24 23:16 UTC by Dan
Modified: 2008-08-06 20:28 UTC (History)
1 user (show)

See Also:
Host:
Target: ia64-hp-hpux11.23
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan 2007-09-24 23:16:34 UTC
I am getting a core dump with a program compiled with gcc-4.1.2 (64bit). The program crashed inside the function call pam_authenticate.

The program uses the pam library and is compiled by the following command:

gcc-4.1.2/bin/gcc -mlp64 pam_test.c -lpam -o pt

-bash-3.00$ ldd pt
        libpam.so.1 =>  /lib/hpux64/libpam.so.1
        libunwind.so.1 =>       /lib/hpux64/libunwind.so.1
        libc.so.1 =>    /lib/hpux64/libc.so.1
        libuca.so.1 =>  /usr/lib/hpux64/libuca.so.1
        libdl.so.1 =>   /usr/lib/hpux64/libdl.so.1

If compiled with 32bit, the program works fine.
gcc-4.1.2/bin/gcc pam_test.c -lpam -o pt

-bash-3.00$ ldd pt
  libpam.so.1 =>  /usr/lib/hpux32/libpam.so.1
        libunwind.so.1 =>       /usr/lib/hpux32/libunwind.so.1
        libc.so.1 =>    /usr/lib/hpux32/libc.so.1
        libuca.so.1 =>  /usr/lib/hpux32/libuca.so.1
        libdl.so.1 =>   /usr/lib/hpux32/libdl.so.1

When compiled using gcc-3.4, it works fine on both 64 and 32 bit.
-bash-3.00$ gcc-3.4/bin/gcc -mlp64 pam_test.c -lpam -o pt
-bash-3.00$ ldd pt
        libpam.so.1 =>  /lib/hpux64/libpam.so.1
        libc.so.1 =>    /lib/hpux64/libc.so.1
        libdl.so.1 =>   /usr/lib/hpux64/libdl.so.1

We built gcc-4.1.2 from the source with the following configuration and with binutil-2.17. 

Configured with: /home/gcc-4.1.2/configure --prefix=/usr/local/gcc-4.1.2 --enable-languages=c,c++ --enable-threads=posix --with-gnu-as --without-gnu-ld --with-as=/usr/local/gcc-4.1.2/bin/as

Is this likely a gcc bug? 
---------------------------------------------------------
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <security/pam_appl.h>

const char *PAM_username = "guest";
const char *PAM_password = "guest";

static int PAM_conv (int num_msg, struct pam_message **msg,
	struct pam_response **resp, void *appdata_ptr)
{
	struct pam_response *repl = NULL;
	int count = 0, replies = 0;
	int size = sizeof(struct pam_response);

	printf("In PAM_conv:num_msg:%i\n",num_msg);
	for(count = 0; count < num_msg; count++) {
		switch(msg[0]->msg_style) {
		case PAM_PROMPT_ECHO_ON:
			printf("PAM_conv:PAM_PROMPT_ECHO_ON\n");

			if (!(repl = (struct pam_response*)realloc(repl, size))) {
				return PAM_CONV_ERR; 
			}
			size += sizeof(struct pam_response);
			repl[replies].resp_retcode = PAM_SUCCESS;
			repl[replies].resp = strdup(PAM_username);
			replies++;
			break;
		case PAM_PROMPT_ECHO_OFF:
			printf("PAM_conv:PAM_PROMPT_ECHO_OFF\n");
			if (!(repl = (struct pam_response*)realloc(repl, size))) {
				return PAM_CONV_ERR; 
			}
			size += sizeof(struct pam_response);
			repl[replies].resp_retcode = PAM_SUCCESS;
			repl[replies].resp = strdup(PAM_password);
			break;
		default:
			break;
		}
	}
	if (repl) {
		*resp = repl;
	}
	return PAM_SUCCESS;
}

int main()
{
	static struct pam_conv conv = {
		 &PAM_conv,
		 NULL
	};
	pam_handle_t *pamh = NULL;
	int retval;
	retval = pam_start("su", PAM_username, &conv, &pamh);
	if (retval != PAM_SUCCESS)
		printf("pam_start() failed.\n");
printf("authenticate--- do not crash\n");
	retval = pam_authenticate(pamh, 0);
printf("authenticate-- \n");
	if (retval != PAM_SUCCESS) {
		printf("PAM authentication failed.\n");
	} else {
		printf("PAM authentication OK.\n");
	}
	pam_end(pamh, PAM_SUCCESS);
	return 1;
}
Comment 1 Andrew Dixie 2007-10-01 01:58:37 UTC
Compile with -Wl,-Z and it succeeds:
gcc-4.1.2/bin/gcc -mlp64 pam_test.c -lpam -o pt -Wl,-Z

It appears libpam on hpux requires -Z.

It was removed here:
http://gcc.gnu.org/ml/gcc-patches/2005-03/msg00542.html
Comment 2 Steve Ellcey 2008-08-06 20:28:12 UTC
I am resolving this as invalid since it is not a GCC bug (unless you consider not using -Z to be a bug).  There is a patch for libpam which should fix the null pointer reference available from HP.  It is HP patch PHCO_37076.