Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to be robust against LinkageError’s from JNA #47

Closed
wants to merge 2 commits into from

Conversation

jglick
Copy link
Member

@jglick jglick commented Sep 11, 2017

An installation encountering kohsuke/akuma#15 which would normally be swallowed here nonetheless had trouble with warnings printed during Pipeline builds:

… FINE    o.j.p.w.s.d.DurableTaskStep$Execution#check: could not check /…
java.lang.UnsatisfiedLinkError: /tmp/jna-…/jna….tmp: /tmp/jna-…/jna….tmp: failed to map segment from shared object: Operation not permitted
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2045)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1928)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1094)
    at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:851)
    at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:826)
    at com.sun.jna.Native.<clinit>(Native.java:140)
    at com.sun.akuma.CLibrary.<clinit>(CLibrary.java:89)
    at com.sun.akuma.JavaVMArguments.resolvePID(JavaVMArguments.java:128)
    at com.sun.akuma.JavaVMArguments.ofLinux(JavaVMArguments.java:116)
    at com.sun.akuma.JavaVMArguments.of(JavaVMArguments.java:104)
    at com.sun.akuma.JavaVMArguments.current(JavaVMArguments.java:92)
    at jenkins.slaves.restarter.UnixSlaveRestarter.canWork(UnixSlaveRestarter.java:29)
    at jenkins.slaves.restarter.JnlpSlaveRestarterInstaller$2.call(JnlpSlaveRestarterInstaller.java:66)
    at jenkins.slaves.restarter.JnlpSlaveRestarterInstaller$2.call(JnlpSlaveRestarterInstaller.java:52)
Caused: java.lang.NoClassDefFoundError: com/sun/jna/Native : cannot initialize class because prior initialization attempt failed
    at org.jenkinsci.plugins.durabletask.ProcessLiveness$LibC.<clinit>(ProcessLiveness.java:117)
    at org.jenkinsci.plugins.durabletask.ProcessLiveness$Liveness.call(ProcessLiveness.java:98)
    at org.jenkinsci.plugins.durabletask.ProcessLiveness$Liveness.call(ProcessLiveness.java:91)
    at …
Caused: java.lang.NoClassDefFoundError: org/jenkinsci/plugins/durabletask/ProcessLiveness$LibC : cannot initialize class because prior initialization attempt failed
    at org.jenkinsci.plugins.durabletask.ProcessLiveness$Liveness.call(ProcessLiveness.java:98)
    at org.jenkinsci.plugins.durabletask.ProcessLiveness$Liveness.call(ProcessLiveness.java:91)
    at …
    at ......remote call to JNLP4-connect connection from …(Native Method)
    at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1537)
    at hudson.remoting.UserResponse.retrieve(UserRequest.java:253)
    at hudson.remoting.Channel.call(Channel.java:822)
Caused: java.io.IOException: Remote call on JNLP4-connect connection from … failed
    at hudson.remoting.Channel.call(Channel.java:830)
    at org.jenkinsci.plugins.durabletask.ProcessLiveness._isAlive(ProcessLiveness.java:77)
    at org.jenkinsci.plugins.durabletask.ProcessLiveness.isAlive(ProcessLiveness.java:59)
    at org.jenkinsci.plugins.durabletask.BourneShellScript$ShellController.exitStatus(BourneShellScript.java:198)
    at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.check(DurableTaskStep.java:307)
    at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.run(DurableTaskStep.java:276)
    at …

Seems we were not catching LinkageErrors in ProcessLiveness correctly, and throwing them up into exitStatus.

@reviewbybees

@@ -96,12 +96,16 @@ private static boolean _isAlive(VirtualChannel channel, int pid, Launcher launch
this.pid = pid;
}
@Override public Boolean call() throws RuntimeException {
// JNR-POSIX does not seem to work on FreeBSD at least, so using JNA instead.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghost
Copy link

ghost commented Sep 11, 2017

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

@jglick
Copy link
Member Author

jglick commented Sep 11, 2017

BourneShellScriptTest.reboot test failure?

@jglick
Copy link
Member Author

jglick commented Sep 11, 2017

Cannot reproduce such a failure locally, and CI server is timing out.

@jglick
Copy link
Member Author

jglick commented Sep 11, 2017

I think this is caused by there being a process with PID=9999 on the test machine. Looking to see if there is some better way to figure this out.

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably collides with other ProcessLiveness and JNR PRs for Cygwin, but seems fine. 🐝

Copy link

@fbelzunc fbelzunc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I would like that you explain why you know you need to check EXACTLY the port 9999. I don't get why you know that this is the PID to start looking.

@jglick
Copy link
Member Author

jglick commented Sep 15, 2017

I don't get why you know that this is the PID to start looking.

We do not. It is just a highish PID number that is unlikely to be in use on a machine which has not done much yet. But it might be, hence the second commit here. We cannot just pick a really high number since the kernel will not accept values outside some range, IIRC 16k or so.

@jglick
Copy link
Member Author

jglick commented Sep 15, 2017

@reviewbybees done

@fbelzunc
Copy link

@jglick I would like this to be merged and released :-)

@jglick
Copy link
Member Author

jglick commented Oct 28, 2017

@fbelzunc then ask @svanoort & @abayer, I am not maintaining this any more.

@jglick
Copy link
Member Author

jglick commented Nov 15, 2017

No longer necessary.

@jglick jglick closed this Nov 15, 2017
@jglick jglick deleted the LinkageError branch November 15, 2017 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants