Tracing down a problem with sudo receiving a stack corruption on one machine, I've found out that a minimal program gets a stack corruption when compiled with gcc-3.4.3, but not when being compiled with HP's bundled "cc". See details here: http://www.sudo.ws/bugs/show_bug.cgi?id=170#c26 The minimal program is this: main() { initgroups("root", 3); } Possible required further conditions are: /etc/group must have "+:" in the last line, /etc/nsswitch.conf should have "compat" for selector "groups", and the machine should be NIS master server. (When removing the "+:" from /etc/group, the gcc-compiled binary also doesn't get a memory fault). I'd like to file a bug report for the HP C library once I know it's not a gcc bug. Upon request I can attach or include disassemblies of both, HP-CC code, and GCC code.
This really sounds like a HP C library bug or bug in the code but I don't know for sure. You are using old style K&R C, can you use -Wall -W and fix all the warnings?
Created attachment 8958 [details] Log file with revised source, disassemblies for both compilers I've revised the source to fix all warnings (except unused formal parameters). Including the declaration or not does not make any difference BTW. I've also added gdb's disassembly of function main for both compilers; gcc-3.4.3, and that of HP-UX 11.11. Finally let me remark that the OS runs 64 bit, but all binaries are 32 bit (which is no problem at all).
This seems more likely to be an HP library bug. I recommend trying the latest libc patch for HP-UX 11.11, PHCO_31903. There is a reference to the HP defect JAGad41604 that may be causing your problem. I don't know why it wouldn't fail when compiled with HP'c C.
Just for reference: The machine in question does not have C-library patch PHCO_31903 installed, but the quoted defect (JAGad41604) doesn't seem to be relevant (The system isn't a trusted one, and only the "hosts" entry in /etc/nsswitch.conf uses "dns", while the "group" entry uses "compat"). I'm hoping someone who really understands the PA assembler can compare the assembly code of both compilers and find out whether there's a significant difference. Having something like Linux' "ltrace" or "valgrind" for HP-UX would be great to track down that problem.
Not a GCC bug.