codon icon indicating copy to clipboard operation
codon copied to clipboard

Open two file with nest "with" statement causes a core dumped

Open xiaxinmeng opened this issue 2 years ago • 1 comments

In a input stream of a file 'fill-in', we open the second file 'fileout', codon crashes.

test.py:

with open('filein') as input:
    with open('fileout') as input:
        pass

Reproduce: codon/codon-linux-x86_64/codon-deploy/bin/codon' run -release test.py

Crash message:

IOError: file filein could not be opened

Raised from: std.internal.file.File.__init__:2
codon/codon-linux-x86_64/codon-deploy/lib/codon/stdlib/internal/file.codon:17:13

Backtrace:
  [0x7ff88b9daaac] GCC_except_table58 at codon/codon-linux-x86_64/codon-deploy/lib/codon/stdlib/internal/file.codon:17:13
  [0x7ff88b9dab2b] GCC_except_table58 at codon/codon-linux-x86_64/codon-deploy/lib/codon/stdlib/internal/file.codon:238:23
  [0x7ff88b9df003] GCC_except_table58 at test.py:237:33
Aborted (core dumped)

Environment: codon: v0.15.5 on Feb 6 Ubuntu 18.04

xiaxinmeng avatar Mar 14 '23 08:03 xiaxinmeng

@xiaxinmeng If the "filein" and/or "fileout" file is missing, it will result in an error, which is the expected behavior. Furthermore, it appears that both files are being opened with the same name, "input".

elisbyberi avatar May 12 '23 23:05 elisbyberi