Skip to content

very weird results when printing fstat results of files using a funcion #1981

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
brandy125 opened this issue Feb 5, 2025 · 3 comments
Closed

Comments

@brandy125
Copy link

I could not yet break down the source of error but it is somehow related to fstat and using it as a return value of a function.
Look this weired example:

openw,1,'erasemelater'
d=1.0
writeu,1,d
close,1

Now lets check the size of that file (the result should be 4 bytes):

bash$ gdl
  GDL - GNU Data Language, Version v1.1-42-gc19e3233

GDL> print,printsize('erasemelater')
% Compiled module: PRINTSIZE.
SIZE            LONG      =  -1232656200
 -1232656200
GDL> 
bash$ gdl
  GDL - GNU Data Language, Version v1.1-42-gc19e3233
GDL> print,printsize('erasemelater')
% Compiled module: PRINTSIZE.
SIZE            LONG      =  -1620301640
 -1620301640
GDL> 

Using the funcion printsize.pro:

function printsize,fname
    openr,dev,fname,/get_lun
    s=fstat(dev)
    size=s.size
    help,size
    return,size
end

In addition to that behaviour comes that if we put a stop inside the function then the value of size is correct.

Version used:

GDL> !gdl
{
    "RELEASE": "1.1-42-gc19e3233",
    "BUILD_DATE": "Feb  5 2025",
    "EPOCH": 1738724400,
    "GDL_USE_DSFMT": 1,
    "GDL_USE_WX": 1,
    "GDL_POSIX": 1
}
GDL> 
@brandy125 brandy125 changed the title very weird results when printing fstat results of files very weird results when printing fstat results of files using a funcion Feb 5, 2025
@jtappin
Copy link

jtappin commented Feb 6, 2025

Very odd! But it gets stranger.

If you add a free_lun, dev then the second (and subsequent) calls give zero as the size!

P.S. file_info is working correctly.

@GillesDuvert
Copy link
Contributor

I made a change recently that seems to have adverse effects.... Thanks for the reports, patching is on its way!

GillesDuvert pushed a commit to GillesDuvert/gdl that referenced this issue Feb 6, 2025
Due to an uncorrect diagnostic of why fstat() would halt if the unt was a pipe (only case at the moment: SPAWN, unit=xxx), the FSTAT function was rendered incorrect.
This patch solves all.
@GillesDuvert
Copy link
Contributor

#1982 solves it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants