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

NPE when blocking in reduce fn (even with auto instrument) #42

Closed
jjcomer opened this issue Jun 21, 2015 · 2 comments
Closed

NPE when blocking in reduce fn (even with auto instrument) #42

jjcomer opened this issue Jun 21, 2015 · 2 comments
Assignees
Labels

Comments

@jjcomer
Copy link

jjcomer commented Jun 21, 2015

If making a blocking call in a reduce (or map) a NPE exception is thrown.
Even with auto instrumentation turned on we are unable to instrument the reduce.

Here is a snippit which reproduces the issue:

(ns actors.test
  (:refer-clojure :exclude [promise await])
  (:require [co.paralleluniverse.pulsar
             [core :refer :all]
             [actors :refer :all]]))

(defsfn action-fn []
  (reduce (fn [acc v]
            (conj acc (join (fiber (inc v)))))
          [] (range 20)))

(defn start-test []
  (join (fiber (action-fn))))

I'm using JDK8 and clojure 1.7.0-RC2 with pulsar 0.7.1-SNAPSHOT

@circlespainter circlespainter self-assigned this Jun 21, 2015
circlespainter pushed a commit that referenced this issue Jun 22, 2015
@circlespainter
Copy link
Member

You should theoretically do '(suspendable! reduce)' and also create the lambda with sfn rather than fn if not using auto-instrumentation, but then Clojure reduce's runtime uses other anonymous functions that should be made suspendable too, so the best way to use standard Clojure's reduce with fiber-blocking code without writing an integration for it is indeed using auto-instrumentation.

Auto-instrumentation explicitly marks Clojure runtime not meant to be used in user calls as non-suspendable though, and it does so for efficiency's sake because this issue http://dev.clojure.org/jira/browse/CLJ-1645 makes it impossible to understand if an interface is a Java one or a Clojure protocol one (votes there are appreciated). reduce was being (wrongly) excluded from auto-instrumentation too, now it should be included instead.

@jjcomer
Copy link
Author

jjcomer commented Jun 22, 2015

Makes sense. Thanks @circlespainter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants