wpilibsuite / allwpilib

Official Repository of WPILibJ and WPILibC
https://wpilib.org/
Other
1.05k stars 611 forks source link

SimHooks.stepTiming SIGSEGV #6064

Closed truher closed 7 months ago

truher commented 9 months ago

Describe the bug Using SimHooks.stepTiming() in tests produces segv's often, but not always.

I'm not an expert at reading hs_err files, but it seems like maybe the problem is in Notifier.cpp in WaitNotifiers()?

For my tests, I don't actually care about notifier behavior, all I want is to change what getFPGATimestamp() returns for code in the main loop. Is there a simpler way to do that?

Desktop (please complete the following information):

Additional context

Here's the hs_err file, truncated to fit this form:

#

A fatal error has been detected by the Java Runtime Environment:

#

SIGSEGV (0xb) at pc=0x00007f0053497ef4, pid=411573, tid=411579

#

JRE version: OpenJDK Runtime Environment Temurin-17.0.8.1+1 (17.0.8.1+1) (build 17.0.8.1+1)

Java VM: OpenJDK 64-Bit Server VM Temurin-17.0.8.1+1 (17.0.8.1+1, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)

Problematic frame:

C [libc.so.6+0x97ef4] pthread_mutex_lock+0x4

#

Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /home/joel/FRC/TRUHER/all24/lib/core.411573)

#

If you would like to submit a bug report, please visit:

https://github.com/adoptium/adoptium-support/issues

The crash happened outside the Java Virtual Machine in native code.

See problematic frame for where to report the bug.

#

--------------- S U M M A R Y ------------

Command Line: -Djava.library.path=/home/joel/FRC/TRUHER/all24/lib/build/jni/release -Djunit.jupiter.extensions.autodetection.enabled=true -Dorg.gradle.internal.worker.tmpdir=/home/joel/FRC/TRUHER/all24/lib/build/tmp/test/work -Dorg.gradle.native=false -javaagent:/home/joel/FRC/TRUHER/all24/lib/build/tmp/.cache/expanded/zip_0bd0851504e6286cb5fc6f37a81e25cc/jacocoagent.jar=destfile=build/jacoco/test.exec,append=true,inclnolocationclasses=false,dumponexit=true,output=file,jmx=false -Xmx512m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 2'

Host: Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz, 6 cores, 62G, Ubuntu 22.04.3 LTS Time: Tue Dec 19 09:26:54 2023 PST elapsed time: 1.164053 seconds (0d 0h 0m 1s)

--------------- T H R E A D ---------------

Current thread (0x00007f004c0294c0): JavaThread "Test worker" [_thread_in_native, id=411579, stack(0x00007f0051f00000,0x00007f0052000000)]

Stack: [0x00007f0051f00000,0x00007f0052000000], sp=0x00007f0051ffae18, free space=1003k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) C [libc.so.6+0x97ef4] pthread_mutex_lock+0x4

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) j edu.wpi.first.hal.simulation.SimulatorJNI.stepTiming(J)V+0 j edu.wpi.first.wpilibj.simulation.SimHooks.stepTiming(D)V+12 j org.team100.lib.commands.drivetrain.DriveInALittleSquareTest.testSteering()V+165 v ~StubRoutines::call_stub j jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0 java.base@17.0.8.1 j jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+133 java.base@17.0.8.1 J 1539 c1 jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; java.base@17.0.8.1 (10 bytes) @ 0x00007f00356fcba4 [0x00007f00356fcb40+0x0000000000000064] J 1538 c1 java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; java.base@17.0.8.1 (65 bytes) @ 0x00007f00356fc77c [0x00007f00356fc660+0x000000000000011c] j org.junit.platform.commons.util.ReflectionUtils.invokeMethod(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+85 j org.junit.jupiter.engine.execution.MethodInvocation.proceed()Ljava/lang/Object;+20 j org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed()Ljava/lang/Object;+16 j org.junit.jupiter.engine.extension.TimeoutExtension.intercept(Lorg/junit/jupiter/api/extension/InvocationInterceptor$Invocation;Lorg/junit/jupiter/api/extension/ReflectiveInvocationContext;Lorg/junit/jupiter/api/extension/ExtensionContext;Lorg/junit/jupiter/engine/extension/TimeoutDuration;Lorg/junit/jupiter/engine/extension/TimeoutExtension$TimeoutProvider;)Ljava/lang/Object;+51 j org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(Lorg/junit/jupiter/api/extension/InvocationInterceptor$Invocation;Lorg/junit/jupiter/api/extension/ReflectiveInvocationContext;Lorg/junit/jupiter/api/extension/ExtensionContext;Lorg/junit/jupiter/engine/extension/TimeoutExtension$TimeoutProvider;)Ljava/lang/Object;+42 j org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(Lorg/junit/jupiter/api/extension/InvocationInterceptor$Invocation;Lorg/junit/jupiter/api/extension/ReflectiveInvocationContext;Lorg/junit/jupiter/api/extension/ExtensionContext;)V+14 j org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor$$Lambda$191+0x00007effd814d9f8.apply(Lorg/junit/jupiter/api/extension/InvocationInterceptor;Lorg/junit/jupiter/api/extension/InvocationInterceptor$Invocation;Lorg/junit/jupiter/api/extension/ReflectiveInvocationContext;Lorg/junit/jupiter/api/extension/ExtensionContext;)V+5 j org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(Lorg/junit/jupiter/engine/execution/ExecutableInvoker$ReflectiveInterceptorCall$VoidMethodInterceptorCall;Lorg/junit/jupiter/api/extension/InvocationInterceptor;Lorg/junit/jupiter/api/extension/InvocationInterceptor$Invocation;Lorg/junit/jupiter/api/extension/ReflectiveInvocationContext;Lorg/junit/jupiter/api/extension/ExtensionContext;)Ljava/lang/Void;+11 j org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall$$Lambda$192+0x00007effd814de18.apply(Lorg/junit/jupiter/api/extension/InvocationInterceptor;Lorg/junit/jupiter/api/extension/InvocationInterceptor$Invocation;Lorg/junit/jupiter/api/extension/ReflectiveInvocationContext;Lorg/junit/jupiter/api/extension/ExtensionContext;)Ljava/lang/Object;+9 j org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(Lorg/junit/jupiter/engine/execution/ExecutableInvoker$ReflectiveInterceptorCall;Lorg/junit/jupiter/api/extension/ReflectiveInvocationContext;Lorg/junit/jupiter/api/extension/ExtensionContext;Lorg/junit/jupiter/api/extension/InvocationInterceptor;Lorg/junit/jupiter/api/extension/InvocationInterceptor$Invocation;)Ljava/lang/Object;+11 j org.junit.jupiter.engine.execution.ExecutableInvoker$$Lambda$346+0x00007effd81760c0.apply(Lorg/junit/jupiter/api/extension/InvocationInterceptor;Lorg/junit/jupiter/api/extension/InvocationInterceptor$Invocation;)Ljava/lang/Object;+14 j org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed()Ljava/lang/Object;+16 j org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(Lorg/junit/jupiter/api/extension/InvocationInterceptor$Invocation;)Ljava/lang/Object;+5 j org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(Lorg/junit/jupiter/api/extension/InvocationInterceptor$Invocation;Lorg/junit/jupiter/engine/execution/InvocationInterceptorChain$InterceptorCall;Ljava/util/List;)Ljava/lang/Object;+40 j org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(Lorg/junit/jupiter/api/extension/InvocationInterceptor$Invocation;Lorg/junit/jupiter/engine/extension/ExtensionRegistry;Lorg/junit/jupiter/engine/execution/InvocationInterceptorChain$InterceptorCall;)Ljava/lang/Object;+51 j org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(Lorg/junit/jupiter/api/extension/InvocationInterceptor$Invocation;Lorg/junit/jupiter/api/extension/ReflectiveInvocationContext;Lorg/junit/jupiter/api/extension/ExtensionContext;Lorg/junit/jupiter/engine/extension/ExtensionRegistry;Lorg/junit/jupiter/engine/execution/ExecutableInvoker$ReflectiveInterceptorCall;)Ljava/lang/Object;+20 j org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(Ljava/lang/reflect/Method;Ljava/lang/Object;Lorg/junit/jupiter/api/extension/ExtensionContext;Lorg/junit/jupiter/engine/extension/ExtensionRegistry;Lorg/junit/jupiter/engine/execution/ExecutableInvoker$ReflectiveInterceptorCall;)Ljava/lang/Object;+89 j org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(Lorg/junit/jupiter/api/extension/ExtensionContext;Lorg/junit/jupiter/engine/execution/JupiterEngineExecutionContext;)V+44 j org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor$$Lambda$358+0x00007effd817c648.execute()V+12 j org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(Lorg/junit/platform/engine/support/hierarchical/ThrowableCollector$Executable;)V+5 j org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(Lorg/junit/jupiter/engine/execution/JupiterEngineExecutionContext;Lorg/junit/platform/engine/support/hierarchical/Node$DynamicTestExecutor;)V+37 j org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(Lorg/junit/jupiter/engine/execution/JupiterEngineExecutionContext;Lorg/junit/platform/engine/support/hierarchical/Node$DynamicTestExecutor;)Lorg/junit/jupiter/engine/execution/JupiterEngineExecutionContext;+111 j org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(Lorg/junit/platform/engine/support/hierarchical/EngineExecutionContext;Lorg/junit/platform/engine/support/hierarchical/Node$DynamicTestExecutor;)Lorg/junit/platform/engine/support/hierarchical/EngineExecutionContext;+10 j org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6()V+108 j org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$284+0x00007effd8165b38.execute()V+4 j org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(Lorg/junit/platform/engine/support/hierarchical/ThrowableCollector$Executable;)V+5 j org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(Lorg/junit/platform/engine/support/hierarchical/EngineExecutionContext;)V+24 j org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$283+0x00007effd8165910.invoke(Lorg/junit/platform/engine/support/hierarchical/EngineExecutionContext;)V+5 j org.junit.platform.engine.support.hierarchical.Node.around(Lorg/junit/platform/engine/support/hierarchical/EngineExecutionContext;Lorg/junit/platform/engine/support/hierarchical/Node$Invocation;)V+6 j org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9()V+18 j org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$282+0x00007effd81654e8.execute()V+4 j org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(Lorg/junit/platform/engine/support/hierarchical/ThrowableCollector$Executable;)V+5 j org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively()V+40 j org.junit.platform.engine.support.hierarchical.NodeTestTask.execute()V+108 j org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService$$Lambda$288+0x00007effd8166650.accept(Ljava/lang/Object;)V+4 j java.util.ArrayList.forEach(Ljava/util/function/Consumer;)V+46 java.base@17.0.8.1 j org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(Ljava/util/List;)V+10 j org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6()V+168 j org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$284+0x00007effd8165b38.execute()V+4 j org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(Lorg/junit/platform/engine/support/hierarchical/ThrowableCollector$Executable;)V+5 j org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(Lorg/junit/platform/engine/support/hierarchical/EngineExecutionContext;)V+24 j org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$283+0x00007effd8165910.invoke(Lorg/junit/platform/engine/support/hierarchical/EngineExecutionContext;)V+5 j org.junit.platform.engine.support.hierarchical.Node.around(Lorg/junit/platform/engine/support/hierarchical/EngineExecutionContext;Lorg/junit/platform/engine/support/hierarchical/Node$Invocation;)V+6 j org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9()V+18 j org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$282+0x00007effd81654e8.execute()V+4 j org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(Lorg/junit/platform/engine/support/hierarchical/ThrowableCollector$Executable;)V+5 j org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively()V+40 j org.junit.platform.engine.support.hierarchical.NodeTestTask.execute()V+108 j org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService$$Lambda$288+0x00007effd8166650.accept(Ljava/lang/Object;)V+4 j java.util.ArrayList.forEach(Ljava/util/function/Consumer;)V+46 java.base@17.0.8.1 j org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(Ljava/util/List;)V+10 j org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6()V+168 j org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$284+0x00007effd8165b38.execute()V+4 j org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(Lorg/junit/platform/engine/support/hierarchical/ThrowableCollector$Executable;)V+5 j org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(Lorg/junit/platform/engine/support/hierarchical/EngineExecutionContext;)V+24 j org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$283+0x00007effd8165910.invoke(Lorg/junit/platform/engine/support/hierarchical/EngineExecutionContext;)V+5 j org.junit.platform.engine.support.hierarchical.Node.around(Lorg/junit/platform/engine/support/hierarchical/EngineExecutionContext;Lorg/junit/platform/engine/support/hierarchical/Node$Invocation;)V+6 j org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9()V+18 j org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$282+0x00007effd81654e8.execute()V+4 j org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(Lorg/junit/platform/engine/support/hierarchical/ThrowableCollector$Executable;)V+5 j org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively()V+40 j org.junit.platform.engine.support.hierarchical.NodeTestTask.execute()V+108 j org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(Lorg/junit/platform/engine/support/hierarchical/HierarchicalTestExecutorService$TestTask;)Ljava/util/concurrent/Future;+5 j org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute()Ljava/util/concurrent/Future;+105 j org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(Lorg/junit/platform/engine/ExecutionRequest;)V+53 j org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(Lorg/junit/platform/engine/TestDescriptor;Lorg/junit/platform/engine/EngineExecutionListener;Lorg/junit/platform/engine/ConfigurationParameters;Lorg/junit/platform/engine/TestEngine;)V+35 j org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(Lorg/junit/platform/launcher/core/LauncherDiscoveryResult;Lorg/junit/platform/engine/EngineExecutionListener;)V+123 j org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(Lorg/junit/platform/launcher/core/InternalTestPlan;Lorg/junit/platform/launcher/core/LauncherDiscoveryResult;Lorg/junit/platform/launcher/TestExecutionListener;)V+29 j org.junit.platform.launcher.core.EngineExecutionOrchestrator$$Lambda$237+0x00007effd8153ad0.accept(Ljava/lang/Object;)V+16 j org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(Lorg/junit/platform/engine/ConfigurationParameters;Lorg/junit/platform/launcher/core/ListenerRegistry;Ljava/util/function/Consumer;)V+80 j org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(Lorg/junit/platform/launcher/core/InternalTestPlan;[Lorg/junit/platform/launcher/TestExecutionListener;)V+58 j org.junit.platform.launcher.core.DefaultLauncher.execute(Lorg/junit/platform/launcher/core/InternalTestPlan;[Lorg/junit/platform/launcher/TestExecutionListener;)V+10 j org.junit.platform.launcher.core.DefaultLauncher.execute(Lorg/junit/platform/launcher/LauncherDiscoveryRequest;[Lorg/junit/platform/launcher/TestExecutionListener;)V+53 j org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(Lorg/junit/platform/launcher/LauncherDiscoveryRequest;[Lorg/junit/platform/launcher/TestExecutionListener;)V+10 j org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses()V+131 j org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(Lorg/gradle/api/internal/tasks/testing/junitplatform/JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor;)V+5 j org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop()V+8 j org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop()V+8 v ~StubRoutines::call_stub j jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0 java.base@17.0.8.1 j jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+133 java.base@17.0.8.1 J 1539 c1 jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; java.base@17.0.8.1 (10 bytes) @ 0x00007f00356fcba4 [0x00007f00356fcb40+0x0000000000000064] J 1538 c1 java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; java.base@17.0.8.1 (65 bytes) @ 0x00007f00356fc77c [0x00007f00356fc660+0x000000000000011c] j org.gradle.internal.dispatch.ReflectionDispatch.dispatch(Lorg/gradle/internal/dispatch/MethodInvocation;)V+31 J 1554 c1 org.gradle.internal.dispatch.ReflectionDispatch.dispatch(Ljava/lang/Object;)V (18 bytes) @ 0x00007f00357015ec [0x00007f0035701540+0x00000000000000ac] j org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(Ljava/lang/Object;)V+34 j org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+288 j jdk.proxy2.$Proxy5.stop()V+9 jdk.proxy2 j org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run()V+11 j org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(Ljava/lang/Runnable;)V+5 j org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(Lorg/gradle/process/internal/worker/WorkerProcessContext;)V+117 j org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(Ljava/lang/Object;)V+9 j org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(Lorg/gradle/process/internal/worker/WorkerProcessContext;)V+90 j org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call()Ljava/lang/Void;+418 j org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call()Ljava/lang/Object;+5 j worker.org.gradle.process.internal.worker.GradleWorkerMain.run()V+347 j worker.org.gradle.process.internal.worker.GradleWorkerMain.main([Ljava/lang/String;)V+11 v ~StubRoutines::call_stub

siginfo: si_signo: 11 (SIGSEGV), si_code: 1 (SEGV_MAPERR), si_addr: 0x0000000000000038

Register to memory mapping:

RAX=0x0000000800000000 is an unknown value RBX={method} {0x00007f001cb0c3b8} 'stepTiming' '(J)V' in 'edu/wpi/first/hal/simulation/SimulatorJNI' RCX=0x0 is NULL RDX=0x0000000000000001 is an unknown value RSP=0x00007f0051ffae18 is pointing into the stack for thread: 0x00007f004c0294c0 RBP=0x000000000030d400 is an unknown value RSI=0x0 is NULL RDI=0x0000000000000028 is an unknown value R8 =0x00007f004c21bb40 points into unknown readable memory: 0x00007f001c48a9d0 | d0 a9 48 1c 00 7f 00 00 R9 =0x0 is NULL R10=0x00007f0024f86260: <offset 0x0000000000006260> in /home/joel/FRC/TRUHER/all24/lib/build/jni/release/libwpiHal.so at 0x00007f0024f80000 R11=0x00007f0024fb7b70: _ZN3hal13WaitNotifiersEv+0x0000000000000000 in /home/joel/FRC/TRUHER/all24/lib/build/jni/release/libwpiHal.so at 0x00007f0024f80000 R12=0x0 is NULL R13={method} {0x00007f001cb0c3b8} 'stepTiming' '(J)V' in 'edu/wpi/first/hal/simulation/SimulatorJNI' R14=0x00007f0051ffaf80 is pointing into the stack for thread: 0x00007f004c0294c0 R15=0x0000000000000028 is an unknown value

Registers: RAX=0x0000000800000000, RBX=0x00007f001cb0c3b8, RCX=0x0000000000000000, RDX=0x0000000000000001 RSP=0x00007f0051ffae18, RBP=0x000000000030d400, RSI=0x0000000000000000, RDI=0x0000000000000028 R8 =0x00007f004c21bb40, R9 =0x0000000000000000, R10=0x00007f0024f86260, R11=0x00007f0024fb7b70 R12=0x0000000000000000, R13=0x00007f001cb0c3b8, R14=0x00007f0051ffaf80, R15=0x0000000000000028 RIP=0x00007f0053497ef4, EFLAGS=0x0000000000010246, CSGSFS=0x002b000000000033, ERR=0x0000000000000004 TRAPNO=0x000000000000000e

Top of Stack: (sp=0x00007f0051ffae18) 0x00007f0051ffae18: 00007f0024fb7be1 00007f0051ffae60 0x00007f0051ffae28: 00007f0051ffaeb0 00007f0025056fc0 0x00007f0051ffae38: 00007f0051ffae01 00007f0051ffaf80 0x00007f0051ffae48: 00007f00250ca730 00007f0051ffae60

Instructions: (pc=0x00007f0053497ef4) 0x00007f0053497df4: 00 00 08 6c 00 00 00 89 c1 48 d3 ea 80 e2 01 0f 0x00007f0053497e04: 84 4f fc ff ff e9 7b ff ff ff 66 90 83 f8 23 0f 0x00007f0053497e14: 85 3f fb ff ff e9 b8 fd ff ff 41 b8 23 00 00 00 0x00007f0053497e24: e9 85 fa ff ff 41 8b 06 83 e0 7f 83 f8 12 74 61 0x00007f0053497e34: 83 f8 11 0f 85 1a fd ff ff 64 48 c7 04 25 f0 02 0x00007f0053497e44: 00 00 00 00 00 00 8b 45 04 83 f8 ff 0f 84 15 ff 0x00007f0053497e54: ff ff 83 c0 01 89 45 04 e9 4d fa ff ff 0f 1f 80 0x00007f0053497e64: 00 00 00 00 be 80 00 00 00 48 89 ef e8 ab 94 ff 0x00007f0053497e74: ff e9 0f ff ff ff 83 c0 0b 83 f8 0b 0f 87 d2 fb 0x00007f0053497e84: ff ff 48 0f a3 c3 0f 83 c8 fb ff ff e9 e3 fc ff 0x00007f0053497e94: ff 64 48 c7 04 25 f0 02 00 00 00 00 00 00 41 b8 0x00007f0053497ea4: 23 00 00 00 e9 01 fa ff ff e8 ae e4 09 00 48 8d 0x00007f0053497eb4: 0d 67 99 14 00 ba b6 01 00 00 48 8d 35 a9 16 14 0x00007f0053497ec4: 00 48 8d 3d b7 16 14 00 e8 7f 1f fa ff 48 8d 0d 0x00007f0053497ed4: 48 99 14 00 ba 53 02 00 00 48 8d 35 8a 16 14 00 0x00007f0053497ee4: 48 8d 3d ae 16 14 00 e8 60 1f fa ff f3 0f 1e fa 0x00007f0053497ef4: 8b 47 10 89 c2 81 e2 7f 01 00 00 90 83 e0 7c 0f 0x00007f0053497f04: 85 a7 00 00 00 53 48 83 ec 10 85 d2 0f 85 a2 00 0x00007f0053497f14: 00 00 44 8b 0d 77 3b 18 00 45 85 c9 75 5e 8b 77 0x00007f0053497f24: 10 81 e6 80 00 00 00 75 0c 64 8b 04 25 18 00 00 0x00007f0053497f34: 00 85 c0 74 37 31 c0 ba 01 00 00 00 f0 0f b1 17 0x00007f0053497f44: 0f 85 ae 00 00 00 8b 4f 08 85 c9 0f 85 5c 01 00 0x00007f0053497f54: 00 64 8b 04 25 d0 02 00 00 89 47 08 83 47 0c 01 0x00007f0053497f64: 90 31 c0 48 83 c4 10 5b c3 0f 1f 00 44 8b 07 45 0x00007f0053497f74: 85 c0 75 c1 c7 07 01 00 00 00 eb ca 8b 47 10 f6 0x00007f0053497f84: c4 03 74 08 f6 c4 01 74 95 eb 07 90 80 cc 01 89 0x00007f0053497f94: 47 10 8b 57 10 48 83 c4 10 48 8d 77 16 5b 81 e2 0x00007f0053497fa4: 80 00 00 00 e9 63 8d ff ff 0f 1f 00 e9 eb f7 ff 0x00007f0053497fb4: ff 0f 1f 00 81 fa 00 01 00 00 74 d6 8b 57 10 83 0x00007f0053497fc4: e2 7f 83 fa 01 0f 85 95 00 00 00 64 8b 04 25 d0 0x00007f0053497fd4: 02 00 00 39 47 08 75 30 8b 47 04 83 f8 ff 0f 84 0x00007f0053497fe4: bf 00 00 00 83 c0 01 89 47 04 31 c0 e9 72 ff ff

Stack slot to memory mapping: stack at sp + 0 slots: 0x00007f0024fb7be1: _ZN3hal13WaitNotifiersEv+0x0000000000000071 in /home/joel/FRC/TRUHER/all24/lib/build/jni/release/libwpiHal.so at 0x00007f0024f80000 stack at sp + 1 slots: 0x00007f0051ffae60 is pointing into the stack for thread: 0x00007f004c0294c0 stack at sp + 2 slots: 0x00007f0051ffaeb0 is pointing into the stack for thread: 0x00007f004c0294c0 stack at sp + 3 slots: 0x00007f0025056fc0: <offset 0x00000000000d6fc0> in /home/joel/FRC/TRUHER/all24/lib/build/jni/release/libwpiHal.so at 0x00007f0024f80000 stack at sp + 4 slots: 0x00007f0051ffae01 is pointing into the stack for thread: 0x00007f004c0294c0 stack at sp + 5 slots: 0x00007f0051ffaf80 is pointing into the stack for thread: 0x00007f004c0294c0 stack at sp + 6 slots: 0x00007f00250ca730: Java_edu_wpi_first_hal_simulation_SimulatorJNI_stepTiming+0x0000000000000000 in /home/joel/FRC/TRUHER/all24/lib/build/jni/release/libwpiHaljni.so at 0x00007f0025086000 stack at sp + 7 slots: 0x00007f0051ffae60 is pointing into the stack for thread: 0x00007f004c0294c0

hs_err_pid411573.log

calcmogul commented 9 months ago

Maybe it's trying to lock a mutex that no longer exists? Sim notifiers have internal race conditions we were never able to figure out that cause CI to fail sometimes.

truher commented 8 months ago

I upgraded to beta 4 and now this happens 100% of the time I use SimHooks.stepTiming or SimHooks.stepTimingAsync.

... which is not great for my test plan.

actually it also segv's when i call getNumNotifiers, whether i use the vscode test runner or the WPILib one.

is there a way to twiddle the fpga time in tests without touching this notifier problem?

calcmogul commented 8 months ago

The SimHooks functions are the only way I know of.

calcmogul commented 8 months ago

Could you post a test project so we can try reproducing it?

truher commented 8 months ago

sure thing, it's here:

https://github.com/Team100/all24/tree/main/studies/simhooks_segv

it is exactly the RobotBase skeleton template, with the addition of this line in Main.main()

NotifierSim.getNumNotifiers();

Then click "simulate robot code" and you get the segv:

C [libc.so.6+0x97ef4] pthread_mutex_lock+0x4

Adding the same line to a vacuous unit test also produces the same outcome.

this is Ubuntu 22.04.3, WPI 2024 beta 4.

thanks for looking into it!

calcmogul commented 8 months ago

I was able to reproduce it in that project with ./gradlew simulateJava as well.

calcmogul commented 8 months ago

Don't you have to initialize the HAL before calling HAL things like Notifiers?

calcmogul commented 8 months ago

Works fine if I move NotifierSim.getNumNotifiers() into the Robot constructor, which is after HAL.initialize() is called. That may have been what happened in the original post as well. We should improve the error message though since it's not hard to hit

truher commented 8 months ago

ah, yeah, same, that fixes it.

i guess i didn't make the connection that SimHooks.stepTiming was a HAL thing at all, since i don't care about the notifier part of it, i'm really just trying to change the FPGA timestamp so that the Timer class reads the right thing.

so maybe this is WAI and there could be some sort of note about calling HAL.initialize?

truher commented 8 months ago

oh also the original issue was a unit test issue, using the vscode test runner. i've had issues with HAL initialization using that method in the past, which is why i knew about HAL.initialize() at all. in the other cases, the error message was something more helpful, like "could not initialize hal" or "can't find hal jni" or whatever. it didn't let the jvm crash.