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

2024-06-20 Thread Basile B. via Digitalmars-d-learn

On Tuesday, 18 June 2024 at 23:07:47 UTC, Murilo 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.
0x555e40b0 in 
_D3std8internal4math11biguintcore7BigUint3powFNaNbNfNkMSQCcQCbQBvQBtQBjmZQs ()


Here is the link to the source code: 
https://github.com/MuriloMir/Fermat-primality-test


That has to be an assertion failure happening at runtime. IIRC 
the `ud2` instruction (causing SIGILL) is used in -betterC mode. 
If you look at biguintcore.d you'll see a couple of them, e.g 
https://github.com/dlang/phobos/blob/master/std/internal/math/biguintcore.d#L1042.


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

2024-06-20 Thread Murilo via Digitalmars-d-learn

On Wednesday, 19 June 2024 at 00:02:38 UTC, H. S. Teoh wrote:

Among the above causes, I'd say (1) is the most likely, (2) is 
the 2nd

most likely if (1) isn't the cause.


Thank you, I will try this software on other computers to see if 
it's number 2. I've reviewed the code and I don't think it could 
be number 1.




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

2024-06-20 Thread Murilo via Digitalmars-d-learn

On Wednesday, 19 June 2024 at 07:46:07 UTC, ryuukk_ wrote:


why do you convert the number to string?


My mistake, I thought BigInt() only took strings, I've corrected 
the code.