Skip to content

race condition in upmap causes null pointer exception #71

@shaunlebron

Description

@shaunlebron

Using upmap sometimes results in this exception:

java.lang.NullPointerException: Cannot invoke "java.util.concurrent.Future.get()" because "fut" is null
core.clj:2317	clojure.core / deref_future
core.clj:2337	clojure.core / deref
impl.clj:58	com.climate.claypoole.impl / deref_fixing_exceptions
impl.clj:58	com.climate.claypoole.impl / deref_fixing_exceptions

It appears that pmap-core zips the ordered tasks with an unordered queue of derefable results of those tasks, and sometimes the second value (returned by a blocking take from the unordered queue) returns nil, causing deref-fixing-exceptions to deref that nil value, throwing the above exception.

So, something in the implementation of the blocking take from the unordered queue is causing it to return nil. I can only guess this is a race condition because it seemed to happen randomly. Anecdotally, I saw it happening more in 1.1.4 than in 1.2.2.

I don’t have steps to reproduce, but we fixed the issue in our system by just switching from upmap to pmap, which avoids what I think is the problematic zip operation above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions