Skip to content

Incompatibility with pthreads #12

@LuckyFellow

Description

@LuckyFellow

Environment

Summary

Without threads, operations work as expected.
As soon as operations are performed in a seperate thread, some result in "INF".

Reproducing Code

<?php

$thread = new class() extends Thread {

    public function run() {
        var_dump((new Decimal\Decimal("1"))->mul("9"));
        var_dump((new Decimal\Decimal("1"))->mul("10"));
    }
};

$thread->start() && $thread->join();
?>

Expected Output

object(Decimal\Decimal)#39 (2) {
  ["value"]=>
  string(1) "9"
  ["precision"]=>
  int(28)
}
object(Decimal\Decimal)#42 (2) {
  ["value"]=>
  string(2) "10"
  ["precision"]=>
  int(28)
}

Actual Output

object(Decimal\Decimal)#3 (2) {
  ["value"]=>
  string(1) "9"
  ["precision"]=>
  int(28)
}
PHP Warning:  Loss of data on string conversion in /app/test.php on line 7
object(Decimal\Decimal)#2 (2) {
  ["value"]=>
  string(3) "INF"
  ["precision"]=>
  int(28)
}

Metadata

Metadata

Assignees

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