Reason for voltage between grounds on Oscilloscope and Function Generator?
The potential difference comes from capacitive coupling between mains voltage side and low voltage side inside the ungrounded power supply. Sometimes you can even feel it by touching only the 9VDC output, and the effect can be amplified if you touch scope ground at the same time. It kind of stings if the contact area to skin is small.

It is either due to pure stray capacitive coupling between the transformer primary and secodary sides, or intentional if there is a so called Y capacitor between primary and secondary sides to reduce electromagnetic interference.

When the power supply output capacitively floats like this, the output may be referenced to ground by few tens if not couple of hundred volts, so connecting it to scope ground will ground the floating output, and the capacitor discharges via oscilloscope ground lead. The spike is short but the current spike during discharge can be quite large. As the capacitor is usually in the order of 2.2 nF, the AC current through it should be below 200 microamps.

This is why many devices with two-prong power supplies say in their manuals that units must be disconnected from mains before connecting to other units.

Just imagine what happens, if you try connecting ground lead between two devices first, and then it happens to disconnect accidentally before you connect another wire between devices, like GPIO pins between two microcontrollers. They could take a couple of hits but get damaged eventually.

So I also suggest not connect powered devices together if they spark while connecting. Unplug them first.