After reconnecting the headphones a lot of times (It happened due to the headphones being in the position just between "plugged" and "unplugged", I guess?), the system's cpu usage jumps to 100% rendering it unusable, the issue didn't resolve itself in 10 minutes. I'm using the default audio drivers.
Apparently the laptop supports headphones with a builtin mic, and it seems the bug is related to the microphone. When running Factorio (or maybe using Discord?), I can't plug these particular headphones in/out at all without stopping the system, but when using other headphones everything seems to be fine.