镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Windows: fix crash when rendering video - #140

Open
32th-System wants to merge 1 commit into
tsoding:masterfrom
32th-System:master
Open

32th-System wants to merge 1 commit into
tsoding:masterfrom
32th-System:master

Conversation

@32th-System

@32th-System 32th-System commented Dec 6, 2025 •

Copy link
Copy Markdown

Becuase stdlib.h was not included, malloc was not declared anywhere. In C, using an undeclared function makes the compiler pretend that it's declared and has a signature of

int func();

meaning that the return value is a 32 bit int and the parameters can be whatever.

As a result of this, after the malloc call, the compiler would insert an instruction to sign extend the lower 32 bits of the RAX register into the upper 32 bits, which would of course create a pointer that is invalid in a lot of cases.

Fixes #137 though I only found this bug report after I already wrote all this other shit

Becuase stdlib.h was included, malloc was not declared anywhere. In C,
using an undeclared function makes the compiler pretend that it's
declared and has a signature of

int func();

meaning that the return value is a 32 bit int and the parameters can be
whatever.

As a result of this, after the malloc call, the compiler would insert an
instruction to sign extend the lower 32 bits of the RAX register into
the upper 32 bits, which would of course create a pointer that is
invalid in a lot of cases
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

Successfully merging this pull request may close these issues.

[msvc] Application crashes when rendering a video

1 participant