79805905

Date: 2025-10-31 14:51:27
Score: 1.5
Natty:
Report link

The solution thanks to @kostix:

I added before PetscInitialize:

if err := PetscOptionsSetValue(nil, "-no_signal_handler", "true"); err != nil {
    panic("could not set option")
}

with

func PetscOptionsSetValue(options c_PetscOptions, name, value string) error {
    c_name := c_CString(name)
    defer c_free(unsafe.Pointer(c_name))
    c_value := c_CString(value)
    defer c_free(unsafe.Pointer(c_value))
    if cIerr := c_PetscOptionsSetValue(options, c_name, c_value); cIerr != 0 {
        return errors.New("Could not PetscOptionsSetValue, error-code: " + strconv.Itoa(int(cIerr)) + "\n")
    }
    return nil
}

and

type c_PetscOptions = C.PetscOptions

func c_PetscOptionsSetValue(options c_PetscOptions, name *c_char, value *c_char) c_PetscErrorCode {
    return C.PetscOptionsSetValue(options, name, value)
}

It also seems working when I moved the setting of the option and the initialization in func init() and remove runtime.LockOSThread().

Reasons:
  • Blacklisted phrase (0.5): thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @kostix
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Fabian