How to link mixing proportion (theta) with a covariate using a link function?

I have also tried with the following model but it gives segfault when running:

functions{
  real vmf_lpdf(row_vector y, row_vector mu, real kappa);
}
data {
  int<lower=0> N; //the number of observations
  vector[N] X; //the model column vector of size N
  matrix[N,3] y; //the multivariate response with N rows and 3 columns
}
parameters {
  vector[2] theta_link;
  real kappa_link;
  unit_vector[3] mu_vec;
}
model {
  real ps[2];
  theta_link ~ normal(0,5);
  for (n in 1:N) {
    vector[2] theta = softmax(theta_link);
    ps[1] = log(theta[1]) + vmf_lpdf(y[n] | mu_vec', exp(X[n]*kappa_link));
    ps[2] = log(theta[2]) + log(1/(4*pi()));
    target += log_sum_exp(ps);
  }
}

The error message is not that informative:

 *** caught segfault ***
address (nil), cause 'unknown'

Traceback:
 1: .External(list(name = "CppMethod__invoke_notvoid", address = <pointer: 0x55c181128b90>,     dll = list(name = "Rcpp", path = "/home/satya/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/libs/Rcpp.so",         dynamicLookup = TRUE, handle = <pointer: 0x55c185336f30>,         info = <pointer: 0x55c180294850>), numParameters = -1L),     <pointer: 0x55c1868b2e30>, <pointer: 0x55c183111740>, .pointer,     ...)
 2: sampler$call_sampler(args_list[[i]])
 3: doTryCatch(return(expr), name, parentenv, handler)
 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 5: tryCatchList(expr, classes, parentenv, handlers)
 6: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call)[1L]        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        sm <- strsplit(conditionMessage(e), "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && isTRUE(getOption("show.error.messages"))) {        cat(msg, file = outFile)        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
 7: try(sampler$call_sampler(args_list[[i]]))
 8: .local(object, ...)
 9: sampling(model, data = list(X = X, N = N, y = y), chains = 1,     iter = 2000)
10: sampling(model, data = list(X = X, N = N, y = y), chains = 1,     iter = 2000)
An irrecoverable exception occurred. R is aborting now ...

Can someone help me with this please?

Edit: I have created another thread about this segfault here: Segfault when using unit_vector and softmax