-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
int.str()
causes Unhandled page fault when built with -shared
on Windows
#23496
Comments
Connected to Huly®: V_0.6-21925 |
This is because V's dll need to call A modified version of your code: #include <stdio.h>
#include <windows.h>
typedef void(*FUNC)();
typedef void (*fn_vinit_caller)();
typedef void (*fn_vcleanup_caller)();
int main(void) {
HMODULE hModule = LoadLibraryW(L"code.dll");
if (hModule == NULL) {
DWORD e = GetLastError();
printf("Failed: %d\r\n", e);
return 1;
}
fn_vinit_caller _vinit_caller = (fn_vinit_caller)GetProcAddress(hModule, "_vinit_caller");
fn_vcleanup_caller _vcleanup_caller = (fn_vcleanup_caller)GetProcAddress(hModule, "_vcleanup_caller");
_vinit_caller(); // call this before any other call
FUNC func = (FUNC)GetProcAddress(hModule, "func");
printf("Begin\r\n");
func();
printf("End\r\n");
_vcleanup_caller(); // call this before you release the dll
return 0;
} |
Oh, we already have |
I want to load my DLL from an external program, how can I handle that? |
See the modified example, that @kbkpbot posted. |
The "external program" I want to use is proprietary and I have no access to the source, so is there any way to call |
|
After apply the PR #23507, you can modify your DLL code as follow: fn C._vinit_caller()
fn C._vcleanup_caller()
@[export: 'func']
fn func() {
C._vinit_caller() // must call first
println('Begin DLL')
for i in 0 .. 10 {
println('${i}')
}
println('End DLL')
C._vcleanup_caller() // must call last, note, currently , it is an empty function....
} Every your export function, should call |
Question. Is possible to make a specific module where to put module dll // xxx.xxx.dll
fn C._vinit_caller()
fn C._vcleanup_caller()
fn init() {
C._vinint_caller()
}
fn cleanup() {
C._vcleanup_caller()
} And then use the above by importing import xxx.xxx.dll as _
@[export: 'func']
fn func() {
println('Begin DLL')
for i in 0 .. 10 {
println('${i}')
}
println('End DLL')
} |
Describe the bug
Calling
int.str()
causes Unhandled page fault on Windows, when the code is built with-shared
Reproduction Steps
I have created a repository for demonstration, and prepared sample binaries built on GitHub Actions.
code.v
:loader.c
:Expected Behavior
The following should be printed:
Current Behavior
On Windows:
On Wine:
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.9 d5aa37d
Environment details (OS name and version, etc.)
GitHub Actions:
Also tested on a real machine:
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: