v
v copied to clipboard
stbi: `C.stbi_load` fails (clang/windows)
Describe the bug
ctx.create_image causes crash whole app while runtime.
Expected Behavior
ctx.create_image creates the image with clang like tcc/gcc.
Current Behavior
App is crashing at runtime. It's output of program.
C:\v-test> v -cc clang -skip-unused run app.v
Unhandled Exception 0xC0000005
print_backtrace_skipping_top_frames is not implemented
signal 11: segmentation fault
print_backtrace_skipping_top_frames is not implemented
Reproduction Steps
Put a random image file named v-logo.png in same directory with the code
import gg
struct App {
mut:
gg &gg.Context = unsafe { nil }
}
fn main() {
mut app := &App{
gg: 0
}
app.gg = gg.new_context(
frame_fn: frame
user_data: app
)
app.gg.create_image("v-logo.png") // crash at the line
app.gg.run()
}
fn frame(mut app App) {
app.gg.begin()
app.gg.end()
}
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.3.3 9794a23
Environment details (OS name and version, etc.)
OS: windows, Microsoft Windows 11 Home v22621 64 bit Processor: 4 cpus, 64bit, little endian, CC version: Error: exec failed (CreateProcess) with code 2: Sistem belirtilen dosyayı bulamıyor. cmd: cc --version
getwd: C:\Users\malisipi vmodules: C:\Users\malisipi.vmodules vroot: C:\Programs\v vexe: C:\Programs\v\v.exe vexe mtime: 2023-02-07 16:27:43 is vroot writable: true is vmodules writable: true V full version: V 0.3.3 09f4845.9794a23
Git version: git version 2.39.1.windows.1 Git vroot status: weekly.2023.04-73-g9794a239 .git/config present: true thirdparty/tcc: N/A
The line causes the crash:
\- https://github.com/vlang/v/blob/master/vlib/gg/image.c.v#L50
\- https://github.com/vlang/v/blob/master/vlib/stbi/stbi.c.v#L120
Also fails stbi_test.v with Clang 15.0.6 on Windows 11 with V 0.3.3 522a9f5 .
Test command: v -cc clang -skip-unused run stbi_test.v
Output:
Source path: C:\Programs\v\examples\assets\logo.png
Unhandled Exception 0xC0000005
print_backtrace_skipping_top_frames is not implemented
signal 11: segmentation fault
print_backtrace_skipping_top_frames is not implemented
Same example works fine with Linux/clang & latest V. That means the bug could be located at Windows-specific code of C library.