Skip to content

Race on global variable: factorials #368

@nasermirzaei89

Description

@nasermirzaei89

We get a RACE error on running tests in the production with the flag -race enabled.
And the stack shows it comes from here:

I believe that the reason is multiple goroutines are calling method ExpTaylor and this method manipulates the shared variable factorials (https://github.com/shopspring/decimal/blob/master/decimal.go#L84).
As you used a global variable for caching factorials (#229), it's not goroutine safe and should have a lock.

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