Why is this happening to my software? An illegal instruction error.

H. S. Teoh hsteoh at qfbox.info
Wed Jun 19 00:02:38 UTC 2024


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


More information about the Digitalmars-d-learn mailing list