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

[jvm-package] SEGV in spark predict with KryoSerializer #191

Closed
raskr opened this issue Aug 3, 2020 · 3 comments · Fixed by #192
Closed

[jvm-package] SEGV in spark predict with KryoSerializer #191

raskr opened this issue Aug 3, 2020 · 3 comments · Fixed by #192

Comments

@raskr
Copy link
Contributor

raskr commented Aug 3, 2020

@hcho3 (cc: @sperlingxx)

Hi, I tested out spark runtime using TreeLiteMode in yarn cluster, and observed JNI call segfaulting.

Let me get straight to the point, for JavaSerializer which is a slow one not commonly used in spark, Serializable implementation in
Preditor.java is sufficient but is not for KryoSerializer. It should implement KryoSerializable as well:

public class Predictor implements Serializable, KryoSerializable {
...

I'll submit a patch fixing this later if there is not problem.

@hcho3
Copy link
Collaborator

hcho3 commented Aug 3, 2020

Thanks!

@hcho3
Copy link
Collaborator

hcho3 commented Aug 3, 2020

Is the issue related to #163 ?

@raskr
Copy link
Contributor Author

raskr commented Aug 3, 2020

Im' not sure. In my case, Predictor object containing a handle to a native runtime was not reconstructed in spark runtime as expected, then segfaulted. The scenario was:

  1. spark driver node initializes the native binary and runtime
  2. the driver serializes and distributes the binary to worker nodes
  3. worker nodes try to deserialize the Predictor instance using KryoSerializer
  4. Kryo doesn't call readObject and uses the default constructor instead to reconstruct it, then this.handle remains 0
  5. any call using TreeliteJNI with handle=0 results in SEGV. (handle=0 is treated as null pointer in C++)

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 a pull request may close this issue.

2 participants