Uh oh!
There was an error while loading. Please reload this page.
[SPARK-25535][core] Work around bad error handling in commons-crypto. - #22557
[SPARK-25535][core] Work around bad error handling in commons-crypto.#22557vanzin wants to merge 3 commits into
Conversation
The commons-crypto library does some questionable error handling internally, which can lead to JVM crashes if some call into native code fails and cleans up state it should not. While the library is not fixed, this change adds some workarounds in Spark code so that when an error is detected in the commons-crypto side, Spark avoids calling into the library further. Tested with existing and added unit tests.
SparkQA
commented
Sep 26, 2018
Test build #96637 has finished for PR 22557 at commit
|
SparkQA
commented
Sep 26, 2018
Test build #96639 has finished for PR 22557 at commit
|
vanzin
commented
Sep 27, 2018
squito
left a comment
There was a problem hiding this comment.
unrelated, but shouldn't EncryptedMessage.transferTo() not keep looping if target.write() doesn't accept all the data?
| } | ||
| intercept[IOException] { | ||
| errorHandler.read(out) | ||
| } |
There was a problem hiding this comment.
since you're throwing a mock IOException above, this would be a little more clear if here you checked the message too
assert(intercept[IOException] {
errorHandler.read(out)
}.getMessage() === ("Cipher stream is closed."))(you can also use assertThrows if you're not looking at the exception at all, though doesn't really matter)
| private var closed = false | ||
| protected def cipherStream: Closeable | ||
| protected def wrapped: Closeable |
There was a problem hiding this comment.
its a little confusing that there are two closeables. I'd add a comment here that wrapped is what the cipherStream is already wrapping, and we want to make sure it gets closed if the cipherStream has an internal error.
(when I see a variable named wrapped, I assumed it was what this was wrapping, not what the cipherStream was wrapping)
| if (mode == Cipher.ENCRYPT_MODE) { | ||
| this.encryptor = null; | ||
| } else { | ||
| this.decryptor = null; |
There was a problem hiding this comment.
any particular reason to set these to null, rather than having an isValid flag in here? you'd get an NPE if you ever tried to use the TranportCipher after this -- you are protecting against that in the wrapping code, but seems you could do it here.
There was a problem hiding this comment.
I can add a check that the ciphers are not null, but no need to have a separate flag. These need to be set to null so that close knows not to try to mess with them.
There was a problem hiding this comment.
Actually the check is already there I'll just add a message to it.
SparkQA
commented
Sep 27, 2018
Test build #96714 has finished for PR 22557 at commit
|
vanzin
commented
Sep 27, 2018
retest this please |
SparkQA
commented
Sep 28, 2018
Test build #96720 has finished for PR 22557 at commit
|
vanzin
commented
Oct 1, 2018
Yes I noticed that too, but separate change. Hopefully I can fix other stuff in commons-crypto that would allow more of that code to be cleaned up... |
squito
commented
Oct 2, 2018
lgtm will leave for a day before mergning |
vanzin
commented
Oct 8, 2018
Ping |
squito
commented
Oct 9, 2018
merged to master |
The commons-crypto library does some questionable error handling internally, which can lead to JVM crashes if some call into native code fails and cleans up state it should not. While the library is not fixed, this change adds some workarounds in Spark code so that when an error is detected in the commons-crypto side, Spark avoids calling into the library further. Tested with existing and added unit tests. Closesapache#22557 from vanzin/SPARK-25535. Authored-by: Marcelo Vanzin <vanzin@cloudera.com> Signed-off-by: Imran Rashid <irashid@cloudera.com>
dongjoon-hyun
commented
Apr 26, 2019
Hi, All. |
dbtsai
commented
Apr 26, 2019
+1 |
vanzin
commented
Apr 26, 2019
Sure. |
…mons-crypto. The commons-crypto library does some questionable error handling internally, which can lead to JVM crashes if some call into native code fails and cleans up state it should not. While the library is not fixed, this change adds some workarounds in Spark code so that when an error is detected in the commons-crypto side, Spark avoids calling into the library further. Tested with existing and added unit tests. Closesapache#22557 from vanzin/SPARK-25535. Authored-by: Marcelo Vanzin <vanzin@cloudera.com> Signed-off-by: Imran Rashid <irashid@cloudera.com> (cherry picked from commit 3eee9e0)
The commons-crypto library does some questionable error handling internally,
which can lead to JVM crashes if some call into native code fails and cleans
up state it should not.
While the library is not fixed, this change adds some workarounds in Spark code
so that when an error is detected in the commons-crypto side, Spark avoids
calling into the library further.
Tested with existing and added unit tests.