Skip to content

GDL 'Direct' function crash on trinary expressions #1576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
GillesDuvert opened this issue Apr 22, 2023 · 3 comments
Closed

GDL 'Direct' function crash on trinary expressions #1576

GillesDuvert opened this issue Apr 22, 2023 · 3 comments
Labels
bug Something isn't working segfault

Comments

@GillesDuvert
Copy link
Contributor

GillesDuvert commented Apr 22, 2023

THIS IS AN INTERNAL ISSUE --- NOT FOR THE FAINT OF HEART

GDL> x=1 & y = 2 & a=0 & b=1 & z=cos(x le y ? a:b)
Segmentation fault (core dumped)

Direct functions are those, like 'cos' that work on a single argument (y=cos(x)) and thus an expression like y=cos(x) can be estimated rapidly if x is a known variable (opposed to an expression that has to be computed). Large gain of speed, for many siple math functions, and corresponds to the vast majority of use-cases. Single arguments like that permit to avoid creating a new environment, so the speed gain, and direct access to the addresses of variables inside the core function ('cos()' in the example).

@GillesDuvert GillesDuvert added bug Something isn't working segfault labels Apr 22, 2023
@GillesDuvert
Copy link
Contributor Author

precision: the crash arises when the returned value of x le y ? a:b is a variable, not an expression:
GDL> a=0 & b=0 & c=0 & z=cos( a ? b:2) ; works, and we note that a ? b:2 gives 2, 2 is a 'value' . cos() is called with isReference=false since a 'value' is not a GDL variable.
GDL> a=0 & b=0 & c=0 & z=cos( a ? 1:b) ; crash! cos() is called with isReference=true since b is a GDL variable.

@GillesDuvert
Copy link
Contributor Author

Also, we have another silliness:

GDL> a=0 & b=0 & c=0 & z=cos( a ? b:!radeg)
% Attempt to write to a readonly variable: !RADEG
% Execution halted at: $MAIN$   

GillesDuvert added a commit to GillesDuvert/gdl that referenced this issue Apr 25, 2023
@GillesDuvert
Copy link
Contributor Author

closed by patch #1579

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working segfault
Projects
None yet
Development

No branches or pull requests

1 participant