Skip to content

fix: ExpTaylor race condition - #414

Merged
mwoss merged 1 commit into
shopspring:masterfrom
Streppel:fix/expTaylor-race-condition
Aug 19, 2026
Merged

fix: ExpTaylor race condition#414
mwoss merged 1 commit into
shopspring:masterfrom
Streppel:fix/expTaylor-race-condition

Conversation

@Streppel

Copy link
Copy Markdown
Contributor

Related: #368

Adds a RWMutex around the shared factorials slice.

@8xmx8 8xmx8 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each call is computed independently; while it may be slightly slower, it is safer and clearer.

func (d Decimal) ExpTaylor(precision int32) (Decimal, error) {
	var factorials = []Decimal{New(1, 0)}
	// Note(mwoss): Implementation can be optimized by exclusively using big.Int API only
	if d.IsZero() {
		return Decimal{oneInt, 0}.Round(precision), nil
	}
···

@senago

senago commented Jul 1, 2026

Copy link
Copy Markdown

Hi! Let's merge and release that fix. I encounter races, and I fear they can lead to pretty bad consequences

@mwoss

mwoss commented Jul 1, 2026

Copy link
Copy Markdown
Member

@Streppel Thank for the PR! Could you rebase so we could merge it? Overall it looks good!

@ArthurMPC

Copy link
Copy Markdown

@Streppel tks for the PR! Lets merge it! lgtm

@Streppel
Streppel force-pushed the fix/expTaylor-race-condition branch from 49e20c9 to 617cdd7 Compare August 4, 2026 16:32
@Streppel

Streppel commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@mwoss rebased!

@mwoss

mwoss commented Aug 19, 2026

Copy link
Copy Markdown
Member

Thanks! Merged

@mwoss
mwoss merged commit ca47408 into shopspring:master Aug 19, 2026
6 checks passed
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 this pull request may close these issues.

5 participants