kohsuke / libpam4j

libpam4j
http://libpam4j.kohsuke.org/
MIT License
44 stars 47 forks source link

On CentOS libpam4j crashes java in PAM.authenticate() #8

Closed jamshid closed 10 years ago

jamshid commented 10 years ago

On some CentOS systems (not all, but seen in 6.2 and 6.5) I'm seeing a crash when there are many (eg, 50) threads calling PAM.pam_authenticate(). Each thread creates and uses its own PAM object (I know they are not thread-safe).

Any idea what the problem might be or where to look for system differences triggering this crash?

The /etc/pam.d/login (the PAM service I'm using) is identical on a working vs failing system. No difference java 1.6 vs 1.7.

I only found one other occurrence of this crash in a google search, mentioned here:

https://issues.jenkins-ci.org/browse/JENKINS-9008?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Here's the stack from hs_error.log:

Stack: [0x00007fe234f5b000,0x00007fe23505c000],  sp=0x00007fe2350588a8,  free
space=1014k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libc.so.6+0x7b6ec]  cfree+0x1c

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  com.sun.jna.Native.invokeInt(JI[Ljava/lang/Object;)I+0
j  com.sun.jna.Function.invoke([Ljava/lang/Object;Ljava/lang/Class;Z)Ljava/lang/Object;+333
j  com.sun.jna.Function.invoke(Ljava/lang/Class;[Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object;+214
j  com.sun.jna.Library$Handler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+341
j  com.sun.proxy.$Proxy7.pam_authenticate(Lorg/jvnet/libpam/impl/PAMLibrary$pam_handle_t;I)I+23
j org.jvnet.libpam.PAM.authenticate(Ljava/lang/String;Ljava/lang/String;)Lorg/jvnet/libpam/UnixUser;+34
jamshid commented 10 years ago

Never mind, it looks like the root bug is in a standard RedHat/CentOS PAM module related to finger print scanners. Fix with "yum remove fprintd-pam". Repro with: https://gist.github.com/jamshid/8776435