| |
![H. S. Teoh's Gravatar profile Gravatar of H. S. Teoh](//www.gravatar.com/avatar/62cf361f36fd5885c467c7f5d7d49fa4?d=identicon&s=32) | Posted by H. S. Teoh in reply to Murilo | Permalink Reply |
|
H. S. Teoh ![H. S. Teoh's Gravatar profile Gravatar of H. S. Teoh](//www.gravatar.com/avatar/62cf361f36fd5885c467c7f5d7d49fa4?d=identicon&s=80)
Posted in reply to Murilo
| On Tue, Jun 18, 2024 at 11:07:47PM +0000, Murilo via Digitalmars-d-learn wrote:
> I've created a software which performs the Fermat's Primality Test, however if I input a very big number it causes an error saying "Illegal instruction (core dumped)". Does anyone know why?
>
> I've used GDB and here is the message:
> Program received signal SIGILL, Illegal instruction.
> 0x00005555555e40b0 in
> _D3std8internal4math11biguintcore7BigUint3powFNaNbNfNkMSQCcQCbQBvQBtQBjmZQs
> ()
[...]
There are a few possible causes:
1) There's a pointer bug in your program that corrupted some memory, causing a function pointer to point to something that isn't a function, and when the CPU tried to execute instructions from there it triggered a fault.
2) The optimized assembly code in std.bigint may contain an instruction that's incompatible with your CPU, so a fault is triggered when the CPU tried to execute it.
3) Your program may have been incorrectly linked, and the ABI incompatibility could have triggered this fault.
4) You may be using std.bigint for numbers far bigger than the range it's designed for. While this is unlikely to be the cause of this error (I've tested std.bigint with numbers up to 100,000+ digits without any crashes), using an unusually large number may cause the code to do something unexpected that may trigger the crash. The chances are pretty low that this is actually the case, though.
Among the above causes, I'd say (1) is the most likely, (2) is the 2nd
most likely if (1) isn't the cause.
T
--
Truth, Sir, is a cow which will give [skeptics] no more milk, and so they are gone to milk the bull. -- Sam. Johnson
|