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; } -- Summary: Core dump on HPUX Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: zhou_dx at yahoo dot com GCC target triplet: ia64-hp-hpux11.23 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33548