Skip to content

vendor:zlib SIGSEGV, Segmentation fault - String passing issue? #5649

@aruscher

Description

@aruscher

Context

Odin: dev-2025-08:2f0b018db
OS: EndeavourOS, Linux 6.15.3-arch1-1
CPU: Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
RAM: 15841 MiB
Backend: LLVM 20.1.6

Expected Behavior

The code below should not produce a SIGSEGV, Segmentation fault

Current Behavior

It produces a SIGSEGV, Segmentation fault

Failure Information (for bugs)

It seems like the passed string VERSION from the zlib_vendor::inflateInit function through the private foreign zlib_vendor::inflateInit2_ function cannot be accessed from the zlib implementation.

Error:

0x00007ffff7f8607a in inflateInit2_ (strm=0x7fffffffe108, windowBits=15, version=0xffffffff <error: Cannot access memory at address 0xffffffff>, stream_size=4244136) at /usr/src/debug/zlib/zlib-1.3.1/inflate.c:183

Stacktrace:

#0  0x00007ffff7f8607a in inflateInit2_ (strm=0x7fffffffe108, windowBits=15, version=0xffffffff <error: Cannot access memory at address 0xffffffff>, stream_size=4218884) at /usr/src/debug/zlib/zlib-1.3.1/inflate.c:183
#1  0x00000000004011d1 in vendor_zlib::inflateInit (strm=0x7fffffffe108, level=-1) at /home/andreasr/Odin/vendor/zlib/zlib.odin:239
#2  0x0000000000405bd4 in main::main () at main.odin:8
#3  0x0000000000402295 in main (argc=1, argv=0x7fffffffe3c8) at /home/andreasr/Odin/base/runtime/entry_unix.odin:57

Steps to Reproduce

package main

import "vendor:zlib"


main :: proc(){
    stream:zlib.z_stream
    zlib.inflateInit(&stream,-1)
    return
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions