Issue2401

classification
Title: SSL race produces NPE
Type: Severity: major
Components: Core Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: nickmbailey, sbenner, zyasoft
Priority: Keywords:

Created on 2015-09-22.18:55:32 by sbenner, last changed 2016-01-22.03:16:42 by zyasoft.

Messages
msg10277 (view) Author: Sylvain Benner (sbenner) Date: 2015-09-22.18:55:32
Executing the same program with the same java runtime environment on my local machines and on a cloud instance (openstack using KVM) both Ubuntu 14.04 yields different results.

The local machine runs the program just fine.
The cloud instance crashes with error

     File "/home/ubuntu/.m2/repository/org/python/jython/2.7/jython-2.7.jar/Lib/ssl.py", line 165, in do_handshake
    _socket.SSLError: [Errno 1] Illegal state exception

I played a bit with the sleep value. Same result up to `0.003` where I get a null pointer.

Environment: openjdk-7 (also tested with oracle jdk 8, same results).
msg10278 (view) Author: Jim Baker (zyasoft) Date: 2015-09-22.21:01:38
We are going need more information to reproduce this problem. In writing the SSL support, I tested this extensively on Ubuntu 14.04 with both OpenJDK 7/8 and Oracle JDK 7/8, and I'm pretty sure it's not specific to cloud or not. (But possibly because of running on KVM or some other way of modifying the network stack.)

It might be worthwhile testing 2.7.1 beta 1, which has been upgraded to Netty 4.0.31
msg10279 (view) Author: Sylvain Benner (sbenner) Date: 2015-09-22.21:03:51
Will do, thank you.
msg10284 (view) Author: Sylvain Benner (sbenner) Date: 2015-09-23.21:21:45
I tried the last 2.7-beta1 and the issue persists but is different, there is no `Illegal state exception` error anymore but only null pointer exceptions, I guess the handshake failed for some reason independent from Jython.

Since the image I tested is an old unsupported Ubuntu image, I decided to test with the new official CentOS image provided by our infrastructure team and it works on it. So we can close this issue as not reproducible, I don't have time to investigate more.

Thank you Jim.
msg10285 (view) Author: Jim Baker (zyasoft) Date: 2015-09-23.21:24:13
Ack, closing out. Sounds like a network stack issue. Thanks for reporting, and we can always reopen this bug if others can reproduce.
msg10643 (view) Author: Nick (nickmbailey) Date: 2016-01-13.21:27:35
I think this might need to be re-opened. I'm able to reproduce this on jython 2.7.1 and ubuntu 14.04. I think it might be a netty bug though. I posted to the netty mailing list to see what they thought:

https://groups.google.com/forum/#!topic/netty/h2ulbfw3uF8

Maybe we can see if they respond before re-opening this issue.
msg10644 (view) Author: Nick (nickmbailey) Date: 2016-01-13.23:01:37
Looks like it's fixed in this open PR https://github.com/netty/netty/pull/4706/files

Unfortunately I don't know how to fix it in jython until that gets merged and released, unless we build a custom netty or something.
msg10645 (view) Author: Jim Baker (zyasoft) Date: 2016-01-13.23:06:54
Right, Netty has already fixed (!) the underlying NPE in https://github.com/netty/netty/pull/4706 for the bug Nick filed https://github.com/netty/netty/issues/4705

We will track here until it we merge in a new formal Netty release (4.0.34), which based on their timeline happens very often. We are currently at 4.0.33, so this should be a smooth transition. In the meantime, we should try building directly against Netty source.

The relevant fix would be in build.xml, replacing 4.0.33 with trial versions of jars.

Needless to say, it's going to be much more awesome when we fix #2182 and move to a Gradle build.
msg10646 (view) Author: Nick (nickmbailey) Date: 2016-01-14.03:39:56
I realized it's fairly simple to fix the issue by subclassing SslHandler. I went ahead and submitted a pull request to fix the issue that way.

https://github.com/jythontools/jython/pull/29
msg10647 (view) Author: Jim Baker (zyasoft) Date: 2016-01-14.05:50:21
Initial workaround in https://hg.python.org/jython/rev/3983294381a0, although we expect this to be resolved in the next release of Netty
History
Date User Action Args
2016-01-22 03:16:42zyasoftsetstatus: pending -> closed
2016-01-14 05:50:21zyasoftsetstatus: closed -> pending
resolution: invalid -> fixed
messages: + msg10647
2016-01-14 03:39:57nickmbaileysetmessages: + msg10646
components: + Core, - Library
2016-01-13 23:30:02zyasoftsettitle: SSL error on cloud instance -> SSL race produces NPE
2016-01-13 23:06:55zyasoftsetassignee: zyasoft
messages: + msg10645
2016-01-13 23:01:38nickmbaileysetmessages: + msg10644
2016-01-13 21:27:35nickmbaileysetnosy: + nickmbailey
messages: + msg10643
2015-09-23 21:24:14zyasoftsetstatus: open -> closed
resolution: invalid
messages: + msg10285
2015-09-23 21:21:46sbennersetmessages: + msg10284
2015-09-22 21:03:51sbennersetmessages: + msg10279
2015-09-22 21:01:38zyasoftsetnosy: + zyasoft
messages: + msg10278
2015-09-22 18:55:32sbennercreate