Calling perf.Stop() immediately after calling perf.StartForAllProcessesAndCPUs() will lead to a crash. This can be reproduced in the xdp_dump example by adding perf.Stop() call after the successful perf.StartForAllProcessesAndCPUs() call.
The initial use case where it was observed was having multiple perf maps, initializing multiple PerfEvents, one for each map, and calling Stop() on the init sequence for the PerfEvents that were already started.
Calling perf.Stop() immediately after calling perf.StartForAllProcessesAndCPUs() will lead to a crash. This can be reproduced in the xdp_dump example by adding perf.Stop() call after the successful perf.StartForAllProcessesAndCPUs() call. The initial use case where it was observed was having multiple perf maps, initializing multiple PerfEvents, one for each map, and calling Stop() on the init sequence for the PerfEvents that were already started.