_set_argv on FreeBSD corrupts the environment

I've not had much time to debug this, but I figured I'd file a ticket so it doesn't get lost. If I find time to debug further, I'll update this ticket.

Observed on stem aee7de8, with arm 853bf8b

On FreeBSD, arm will break in many ways because _set_argv clobbers the environment:

  • os.putenv(LANG...) will fail because the environment is corrupt and Python will stop with EFAULT
  • If you manage to get past that, every system() call will fail because of unexpected input on stderr (sh: environment corrupt; missing value for [sic])

At first guess, the check for > _MAX_NAME_LEN in get_process_name() is probably incorrect.

Trac:
Username: philip