Comments (13)
From madExcept
disassembling:
[...]
0040fbcf mov edx, [edx]
0040fbd1 push eax
0040fbd2 call -$1583 ($40e654) ; System.@FinalizeArray
0040fbd2
0040fbd7 pop eax
0040fbd2
0040fbd8 loc_40fbd8:
0040fbd8 sub eax, 8
0040fbdb call -$858c ($407654) ; System.@FreeMEM
0040fbdb
0040fbe0 > pop eax
0040fbdb
0040fbe1 loc_40fbe1:
0040fbe1 ret
from delphibignumbers.
Tried this also in product, behaves identically as the Unit-test project
Is this an bug, or FastMM option problem, don't know. Wait a sec, I'll try build product in release mode...
Works in a release mode, so it must be FastMM check.
Don't know is it because of FastMM is hyper sensitive, or is there actually an bug... I'll attach
my FastMM settings in this message.
from delphibignumbers.
Tested this with fresh project with FastMM4 in debug mode and the problem is the same. So it is not relat to projects it supposed to go in.
Have no idea so far how to prevent FastMM to go haywire on this.
I am all ears ;)
from delphibignumbers.
Seems that it could actually be an bug : http://techqa.info/programming/question/10329940/fastmm4-says-
FastMM in full Debug mode allocates bit more memory to the block and adds known value in that part. In FreeMem it checks if the known value still there, if not, that error is raised. So if memory is written past it's bounds it can be detected when it freed.
from delphibignumbers.
Error still exists. Checked this with the very latest version from repository.
from delphibignumbers.
I tried with this simple test program. No problems in either Win32 or Win64. What are the input and output you get?
program BigIntStrModIssue;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Velthuis.BigIntegers;
function BigIntegerStrMod(const ABigInteger: string; const Adivider: Integer): Integer;
var
LBigInt: BigInteger;
LDivisor: BigInteger;
LRemainder: BigInteger;
begin
// Alkuarvo
if not BigInteger.TryParse(ABigInteger, LBigInt) then
raise Exception.CreateFmt('Virheellinen numero %s', [ABigInteger]);
LDivisor := BigInteger.Create(Adivider);
LRemainder := BigInteger.Create(0);
// Lasketana ja Palautetaan
LRemainder := LBigInt mod LDivisor;
Result := LRemainder.AsInteger;
end;
var
I: Integer;
begin
try
I := BigIntegerStrMod('1234567890123456789123456789', 12345678);
Writeln(I);
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
Readln;
end.
from delphibignumbers.
Did you use FastMM to check buffer overrun? Because just running it without FastMM debug-mode checks doesn't show the problem. Most likely by sheer luck, memory gets written in places where it doesn't matter.
FastMM in debug mode puts known values at the end of the memory block. Is that known value changes it'll give error on freemem.
from delphibignumbers.
Yes, I checked in several programs. There was a leak in InternalRightShift
. Didn't find anything else. But I printed out your stack trace and will see what I can find. Seems to be AllocNewMagnitude
and MakeSize
. Will revisit.
from delphibignumbers.
Tried with the latest FastMM4. And indeed, I get the same report. It seems to be TryParse
causing the problem, as it doesn't happen if I use other ways to initialize LBigInt
. Will see what I can do.
from delphibignumbers.
from delphibignumbers.
Checked that much that it behaves similarly built with purepascal-define.
So it is not just error in ASM-optimization.
from delphibignumbers.
Found quite a few buffer overruns (or actually badly dimensioned arrays). Should all be fixed now (crossing fingers). Took me a lot of grumbling and pulling hair. Time to see my hair stylist tomorrow, to see if she can save some of it. <g>
from delphibignumbers.
Don't see the error anymore. So big thanks to you. Keep up the good work!
from delphibignumbers.
Related Issues (16)
- Error in BigIntegers.Primes HOT 2
- Range check error HOT 2
- Results of Divide, Sqrt etc. for precise numbers is zero HOT 2
- Wrong Round?
- mod operator returns negative values (e.g. -15 mod 5 = -3, but should be 1) HOT 1
- C++ Builder
- A rare error when parsing huge integers
- not thread-safe
- BigDecimal.Sqrt always gets divide by zero error. HOT 2
- Velthuis.BigIntegers.Primes Problem
- IsProbablePrime runs in endless loop when passing "3" HOT 2
- Possibly wrong date format HOT 2
- FreePascal Support HOT 1
- Wrong exception message if calculate Sqrt of negative number HOT 1
- Compilation error in BigIntegers if "Typed @ operator is true" HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from delphibignumbers.