function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bhuvan PashamBhuvan Pasham 

FATAL_ERROR Internal Salesforce.com Error for simple multiplications in Apex

Apex code is failing with an obscure error on simple arithmatic. I am new to salesforce trying to port .Net application to force.com. In my 25+ years of programming career, I always assumed this is the fundamental to programming and multiplication never fails. 
Can anyone suggest what might be happening here please...

invx = Amount * pct; //All three varibles are declared double; Amount = 1000000; pct = 0.00341000000;

Please help...

Here is the log ---
3.82119E8,"LegalEntity":"0x2571e4d6","LocalAmount":1000000,"Tranche":"0xeae7d67","TransType":"0x509ac97c"}|0x441684fe
09:13:52.4 (270584532)|VARIABLE_ASSIGNMENT|[92]|pct|0.007850957424257888
09:13:52.4 (270589471)|STATEMENT_EXECUTE|[93]
09:13:52.4 (270598139)|HEAP_ALLOCATE|[93]|Bytes:5
09:13:52.4 (270616177)|ENTERING_MANAGED_PKG|
09:13:52.4 (270637775)|HEAP_ALLOCATE|[93]|Bytes:20
09:13:52.4 (270650886)|HEAP_ALLOCATE|[93]|Bytes:25
09:13:52.4 (270663155)|ENTERING_MANAGED_PKG|
09:13:52.4 (270666682)|USER_DEBUG|[93]|DEBUG|PCT: 0.007850957424257888
09:13:52.4 (270673475)|STATEMENT_EXECUTE|[94]
09:13:52.4 (270680995)|HEAP_ALLOCATE|[94]|Bytes:8
09:13:52.4 (270748567)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this|{"AllocationRule":"0x78883bfd","Amount":1000000,"EffectiveDate":"2016-06-22T00:00:00.000Z","Fund":"0x15ef0b75","FundCommitment":3.82119E8,"LegalEntity":"0x2571e4d6","LocalAmount":1000000,"Tranche":"0xeae7d67","TransType":"0x509ac97c"}|0x441684fe
09:13:52.4 (270776435)|ENTERING_MANAGED_PKG|
09:13:52.4 (270781172)|HEAP_ALLOCATE|[94]|Bytes:7
09:13:52.4 (270792207)|HEAP_ALLOCATE|[94]|Bytes:15
09:13:52.4 (270802287)|ENTERING_MANAGED_PKG|
09:13:52.4 (270805630)|USER_DEBUG|[94]|DEBUG|Amount: 1000000
09:13:52.4 (270812096)|STATEMENT_EXECUTE|[95]
09:13:52.4 (270874136)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this|{"AllocationRule":"0x78883bfd","Amount":1000000,"EffectiveDate":"2016-06-22T00:00:00.000Z","Fund":"0x15ef0b75","FundCommitment":3.82119E8,"LegalEntity":"0x2571e4d6","LocalAmount":1000000,"Tranche":"0xeae7d67","TransType":"0x509ac97c"}|0x441684fe
09:13:52.4 (271195406)|FATAL_ERROR|Internal Salesforce.com Error
09:13:52.271 (271208621)|CUMULATIVE_LIMIT_USAGE

 
Best Answer chosen by Bhuvan Pasham
Bhuvan PashamBhuvan Pasham
@Anupama - worked with salesforce support and got it resolved. Seems like this only happens when the numbers are coming from JSON deserialization - from Lightning Components. Happenning on any arithmetic inside an Apex controller between any number from UI and database. Looks like a serious platform level issue - but workable. Have to convert inputnumbers using double.valueOf(n).

All Answers

Anupama SamantroyAnupama Samantroy
Hi Bhuvan,

It is wierd. Worked perfectly fine for me. I can see that your code is entering a managed package. Could be some issue there. Can you check.

Thanks
Anupama
Bhuvan PashamBhuvan Pasham
@Anupama - worked with salesforce support and got it resolved. Seems like this only happens when the numbers are coming from JSON deserialization - from Lightning Components. Happenning on any arithmetic inside an Apex controller between any number from UI and database. Looks like a serious platform level issue - but workable. Have to convert inputnumbers using double.valueOf(n).
This was selected as the best answer