tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: gcc -O2 produces invalid object code (x86_64, netbsd-5 branch)



David Holland wrote:
On Mon, Mar 08, 2010 at 12:57:51AM -0500, Richard Hansen wrote:
I've been debugging a strange libpam segfault on the netbsd-5 branch (amd64) and I've concluded that gcc -O2 is incorrectly compiling the pam_end() function in src/dist/openpam/lib/pam_end.c. gcc -O0 works fine.

Check <security/pam_appl.h>. The pamh argument is declared __attribute__((__nonnull__())), so the compiler is merely optimizing according to things it's been told. The caller is wrong and should not be passing NULL.

Ah, good catch!

So the bug isn't in gcc, it's in openpam: either the pam_end(3) man page should be updated to say that pamh must be non-NULL, or the attribute should be removed from the declaration. Which do people prefer?

If the API spec is updated to say that NULL can't be passed, then passwd needs to be fixed (there's an error case that causes it to pass NULL to pam_end()).

Thanks,
Richard


Home | Main Index | Thread Index | Old Index