这是indexloc提供的服务,不要输入任何密码
Skip to content

core:os/os2 read_entire_file creates infinite loop #3279

@marcs-feh

Description

@marcs-feh

Context

odin report

Odin:    dev-2024-03:04f0fbf23
OS:      Arch Linux, Linux 6.6.21-1-lts
CPU:     Intel(R) Celeron(R) N4020 CPU @ 1.10GHz
RAM:     3471 MiB
Backend: LLVM 17.0.5

Expected Behavior

read_entire_file should simply read the whole file into a buffer allocated with a particular allocator.

Current Behavior

An infinite loop is created when reading a file, the issue seems to be in core/os/os2/file_util.odin in the procedure read_entire_file_from_file. Running it on a debugger shows the bug happens during the reading loop:
image

Steps to Reproduce

Example bug.odin

package bug

import "core:fmt"
import os "core:os/os2"

main :: proc(){
	f, err := os.read_entire_file("foo.txt", context.allocator)
	fmt.println("Error:", err)
	fmt.println("File data:", f)
}
echo 'Hellope' > foo.txt
odin build bug.odin -file
./bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions