gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
276 stars 61 forks source link

GDL segfaults when dividing by 0 #1746

Closed brandy125 closed 8 months ago

brandy125 commented 8 months ago

Just noticed that the latest version segfaults when dividing by 0:

GDL> 5/0
Floating point exception (core dumped)

Can anybody confirm?

frankmri commented 8 months ago

Yes I can confirm

GDL> print, 5/0 Floating point exception (core dumped) But, GDL> print, 5./0 Inf % Program caused arithmetic error: Floating divide by zero works as expected...

Best Frank

brandy125 commented 8 months ago

ok, thanks!

On 9. Feb 2024, at 11:43, frankmri @.***> wrote:

Yes I can confirm

GDL> print, 5/0 Floating point exception (core dumped) But, GDL> print, 5./0 Inf % Program caused arithmetic error: Floating divide by zero works as expected...

Best Frank

— Reply to this email directly, view it on GitHub https://github.com/gnudatalanguage/gdl/issues/1746#issuecomment-1936057547, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOC5K6GCVNWFQORWY6MREMLYSYY2ZAVCNFSM6AAAAABDAFYM2SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZWGA2TONJUG4. You are receiving this because you authored the thread.

alaingdl commented 8 months ago

I confirm. I am sorry for that. I think it is related to #1683 @GillesDuvert (before I have no crash)

That's also mean we don't test enough. sorry.

A question to @GillesDuvert : more details on speed improvement mentioned in the discussion ? thanks !

GillesDuvert commented 8 months ago

This is not about speed improvements, it is about catching divide by zero and other exceptions and report them, as described in #1683. Sorry for the inconvenience, will patch ASAP.

GillesDuvert commented 8 months ago

actually, FPE (Floating Point Exceptions) are well handled (so my own tests passed) GDL> a=3./0. % Program caused arithmetic error: Floating divide by zero

The untested behaviour here is integer division, which is NOT catcheable and has an undefined behaviour. It comes from a code line that has been lost in... changes related to speed improvements (argh... :blush: ) where it was painfully tested for each cases of integer division. To be patched soon.

GillesDuvert commented 8 months ago

I'm glad to announce that #1747 closes this (hopefully minor) incident. A new test procedure has been installed to avoid futur problems. Thanks!