Adam S
05/05/2023, 12:36 PMJPC_BodyInterface_CreateBody
JPC_Body *floor = JPC_BodyInterface_CreateBody(body_interface, &floor_settings);
my Kotlin code is in the thread 🧵
I guess it’s a problem with passing in the floor_settings
pointer? Or maybe body_interface
isn’t stable? Do I need to pin it?Adam S
05/05/2023, 12:37 PMAdam S
05/05/2023, 12:41 PM<snip>
creating static floor body...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':modules:interop-jolt:runDebugExecutableMacosX64'.
> Process 'command '/projects/jolt/build/bin/macosX64/debugExecutable/interop-jolt.kexe'' finished with non-zero exit value 139
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':jolt:runDebugExecutableMacosX64'.
...
Caused by: org.gradle.process.internal.ExecException: Process 'command '/projects/jolt/build/bin/macosX64/debugExecutable/interop-jolt.kexe'' finished with non-zero exit value 139
...
vbsteven
05/05/2023, 12:43 PM.kexe
directly (not from intellij) and it might show you some more info. exit value 139 is probably a segfaultAdam S
05/05/2023, 12:44 PMcreating static floor body...
[1] 1444 segmentation fault ./build/bin/macosX64/debugExecutable/interop-jolt.kexe
vbsteven
05/05/2023, 12:46 PMvbsteven
05/05/2023, 12:46 PMcreating static floor body
logsAdam S
05/05/2023, 12:46 PMAdam S
05/05/2023, 12:47 PMJPC_BodyInterface_CreateBody
that’s failing
println("creating static floor body...")
val floor = JPC_BodyInterface_CreateBody(
in_iface = bodyInterface,
in_setting = floorSettings.ptr,
)
Adam S
05/05/2023, 12:48 PMfloorSettings.ptr
, since that’s used in JPC_BodyCreationSettings_Set()
and it correctly updates the values of floorSettings
Adam S
05/05/2023, 12:50 PMbodyInterface
val bodyInterface: CPointer<JPC_BodyInterface> =
JPC_PhysicsSystem_GetBodyInterface(physicsSystem)!!
println("bodyInterface: $bodyInterface")
but this prints bodyInterface: CPointer(raw=0x7fe76300a5b0)
, which seems okayAdam S
05/05/2023, 12:51 PMJPC_BodyInterface
, doesn’t have any properties - maybe K/N gets confused about the size?
typedef struct JPC_BodyInterface JPC_BodyInterface;
vbsteven
05/05/2023, 1:02 PMvbsteven
05/05/2023, 1:03 PMAdam S
05/05/2023, 1:05 PMval bodyInterface: CPointer<JPC_BodyInterface> =
JPC_PhysicsSystem_GetBodyInterface(physicsSystem)!!
println(" 99u added?: ${JPC_BodyInterface_IsAdded(bodyInterface, 99u)}")
Jeff Lockhart
05/05/2023, 2:57 PMkotlin.native.binary.sourceInfoType=libbacktrace
to gradle.properties to get better stack traces in Kotlin/Native. It doesn't work with Windows targets though, so if you have a Windows target, you can selectively enable it in build.gradle.kts:
targets.withType<KotlinNativeTarget> {
if (konanTarget.family != Family.MINGW) {
binaries.all {
binaryOptions["sourceInfoType"] = "libbacktrace"
}
}
}
Adam S
05/05/2023, 9:58 PMcValue<FooStruct> {}
, which apparently is wrong 🤷♀️
private fun MemScope.createBodyActivationListener(): CValue<MyActivationListener> {
return cValue<MyActivationListener> {
vtable = cValue<JPC_BodyActivationListenerVTable> {
OnBodyActivated = staticCFunction { _, _, _ -> /*...*/ }
OnBodyDeactivated = staticCFunction { _, _, _ -> /*...*/ }
}.ptr
}
}
instead I changed cValue<FooStruct> {}
to alloc<FooStruct> {}
private fun AutofreeScope.createBodyActivationListener(): MyActivationListener {
return alloc<MyActivationListener> {
vtable = alloc<JPC_BodyActivationListenerVTable> {
OnBodyActivated = staticCFunction { _, _, _ -> /*...*/ }
OnBodyDeactivated = staticCFunction { _, _, _ -> /*...*/ }
}.ptr
}
}
Landry Norris
05/05/2023, 10:11 PMAdam S
05/06/2023, 8:32 AM.ptr
is a function provided by MemScope
, and because createBodyActivationListener()
was re-using the same MemScope
as was used across my whole app I expected the pointer to be stableLandry Norris
05/06/2023, 12:36 PMAdam S
05/06/2023, 12:38 PMfun main(): Unit = memScoped {
...
}
and then all of the functions extended MemScope
, so the same one was used