Skip to content

SIGSEGV at compile time: compound assignment through a property pair under a nested field of deref(p + k) #17

Closed

Description

@lookibed

Compound assignment through a property pair (operator .s / operator .s:=) whose base is a nested field of deref(p + k) crashes the compiler with SIGSEGV before main runs. A plain store, a plain field, deref(p), deref(q) after var q = p + 2, and an array element all work.

daScript at c4e4906 (lookibed fork), linux x86_64, interpreter (the crash is at compile time, so every tier).

Repro (z_n.das, run with daslang z_n.das; prints nothing, exit code 139):

options gen2
struct U {
    x : int
}
def operator .s(u : U) : int {
    return u.x
}
def operator .s:=(var u : U; v : int) {
    u.x = v
}
struct S {
    u : U
}
var arr : S[4]
[export]
def main {
    to_log(LOG_ERROR, "start\n")
    unsafe {
        var p : S? = addr(arr[0])
        deref(p + 2).u.s += 1
        to_log(LOG_ERROR, "{arr[2].u.s}\n")
    }
}

Forms that compile and run as expected:

deref(p).u.s += 1
var q = p + 2
deref(q).u.s += 1
arr[2].u.s += 1
deref(p + 2).u.x += 1
deref(p + 2).u.s = 5
deref(p + 2).s += 1

Forms that crash: deref(p + 2).u.s += 1, deref(p + k).u.s += 1 with k a variable, and the same through a [c_bitfields]-style generated property pair.

Found by c2das-re (a C to daslang converter): C p[2].u.s++ on a bitfield member reached through pointer arithmetic. The converter now spells the step as x = x + 1 to avoid it.

Activity

  1. lookibed commented on Nov 9, 2026

    @lookibed
    OwnerAuthor

    Re-checked by the owner from this issue's reproducer on daScript abf1d40 (0.6.5): fixed upstream (GaijinEntertainment/daScript 2131620 GaijinEntertainment#4472 dasLLVM, 1404d5a GaijinEntertainment#4480 optimizer, f386f92 GaijinEntertainment#4482 cache and tools). The c2das-re probes were re-pinned in the repin PRs (lookibed/c2das-re#142-GaijinEntertainment#147; ruling 38 addendum 4).

  2. lookibed commented on Nov 9, 2026

    @lookibed
    OwnerAuthor

    Fixed upstream: GaijinEntertainment#4449 is closed and the fix is in master abf1d40e35 (0.6.5). Verified by running this issue's repro on a build of that commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions