flat assembler
Message board for the users of flat assembler.

Index > Main > include bug

Author
Thread Post new topic Reply to topic
jiangfasm



Joined: 08 Mar 2015
Posts: 60
jiangfasm 28 Sep 2020, 15:15
Code:
tst$ tree
.
├── asm.asm
└── Win32
    ├── executable.inc
    └── Win
        └── executable.inc
                
tst$ cat asm.asm
include 'Win32/executable.inc'

tst$ cat ./Win32/executable.inc
include 'Win/executable.inc'
include '%TargetOS%/executable.inc' ;<----error

tst$ cat ./Win32/Win/executable.inc

tst$ fasm asm.asm
flat assembler  version 1.73.25  (1048576 kilobytes memory)
Win32///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////executable.inc [1]:
include 'Win/executable.inc'
error: file not found.    


The error is on the second line


Description:
Download
Filename: tst.rar
Filesize: 421 Bytes
Downloaded: 446 Time(s)

Post 28 Sep 2020, 15:15
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 28 Sep 2020, 17:31
When "TargetOS" environment variable is not defined on your system, "%TargetOS%" is replaced with empty string and therefore you can get the same behavior with this source:
Code:
include 'Win/executable.inc'
include '/executable.inc'    

What this setup ends up doing is that the file starts recursively including itself. If the path did not have that "/" at the start:
Code:
include 'Win/executable.inc'
include 'executable.inc' ; infinite recursion    
then you would get a much more simpler error:
Code:
flat assembler  version 1.73.25  (1048576 kilobytes memory)
error: out of stack space.    
However, because there is that "/", additional copy of it ends up appended on each level of the recursion. And interestingly, there is a limit of how many delimiters OS allows to have in a path (here tested on Windows command line):
Code:
C:\test>type Win32\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\executable.inc
;include 'Win/executable.inc'
include '/executable.inc' ;<----error

C:\test>type Win32\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\executable.inc
The system cannot find the path specified.    
With just one delimiter more, OS is no longer able to find the file.

Because of that, the "include" recursion is cut short, because as soon as the number of slashes reaches the OS's limit, fasm no longer finds a file there. So instead of running out of stack space because of infinite recursion, you end up having this strange error with multiplied delimiters just at the edge of OS's tolerance.
Post 28 Sep 2020, 17:31
View user's profile Send private message Visit poster's website Reply with quote
jiangfasm



Joined: 08 Mar 2015
Posts: 60
jiangfasm 29 Sep 2020, 03:43
You're awesome!
It would be nice if FASM's error prompt could be more friendly
Post 29 Sep 2020, 03:43
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.