Opened 5 years ago

Closed 4 years ago

#3815 defect closed invalid (invalid)

Some Flash Player installers may crash on XP when launched by Twisted

Reported by: ivank Owned by: ivank
Priority: normal Milestone:
Component: core Keywords: windows
Cc: exarkun Branch:
Author: Launchpad Bug:

Description

One of my Windows processes was having strange crashes. I narrowed it down to Twisted setting the full path as the first argument.

twisted/internet/utils.py _callProtocolWithDeferred looks like this:

def _callProtocolWithDeferred(protocol, executable, args, env, path, reactor=None):
    if reactor is None:
        from twisted.internet import reactor

    d = defer.Deferred()
    p = protocol(d)
    reactor.spawnProcess(p, executable, (executable,)+tuple(args), env, path)
    return d

but

reactor.spawnProcess(p, executable, (executable,)+tuple(args), env, path)

should probably be

reactor.spawnProcess(p, executable, (os.path.split(executable)[1],)+tuple(args), env, path)

because getProcessOutput gives _callProtocolWithDeferred the full executable path.

Attachments (1)

flash-9-installer-crash-under-twisted.png (77.2 KB) - added by ivank 4 years ago.
screenshot of crash

Download all attachments as: .zip

Change History (16)

comment:1 Changed 5 years ago by exarkun

  • Cc exarkun added

Erm.

Is this a crazy Windows thing?

Having the full path to the executable as argv[0] is good.

comment:2 Changed 5 years ago by ivank

Maybe it is just a crazy Windows thing.

I believe it is valid to have a full path in lpCommandLine, but (as far as my very bad guessing goes), that is not the behavior when double-clicking on a file, or when typing out and running a full D:\Win\Path\To\Something.exe through cmd.exe

So, if my guess about lpCommandLine is right, then Twisted does something unexpected.

comment:3 Changed 5 years ago by ivank

So if my guess is right, this is more about t.i._dumbwin32proc, and not t.i.utils.

comment:4 Changed 5 years ago by exarkun

I think the Windows process you were running was the Adobe Flash installer? Is there any hope of a simpler, more self-contained reproduction of this issue?

comment:5 Changed 5 years ago by glyph

It looks like Python expects the behavior that ivan describes from Windows and explicitly works around it. If you look at the code to PySys_SetArgv, you'll notice an "#ifdef MS_WINDOWS" that calls GetFullPathName on argv0.

The Windows-y way of locating the executable you're running from is apparently to call GetModuleFileName with 0, not to look at argv.

comment:6 Changed 5 years ago by exarkun

Okay, so it sounds like this is a real bug in our Windows process implementation, and to test it we'll need a custom C program, since for anything written in Python, CPython will get in the way?

comment:7 Changed 5 years ago by ivank

I was wrong about "when typing out and running a full path" above; when I type out and run a full path in cmd.exe, the executable does have argv[0] set to the full path.

comment:8 Changed 5 years ago by ivank

And I don't think Windows is doing any argv magic like Python because running it without the full path in cmd.exe leads to a short (just basename) argv[0]

comment:9 Changed 5 years ago by ivank

I replicated the crash about a hundred times yesterday, but I can no longer replicate the crash on the single virtual machine that had the problem. I probably should have taken a snapshot.

comment:10 Changed 5 years ago by ivank

Double-clicking in explorer also seems to give the child the full path for argv[0]. But when I could replicate the crash, it crashed only from Twisted's execution environment. Maybe there was something else different about the environment, or only a combination of things led to the crash. Or maybe lpCommandLine ends up in more places than argv[0]

If it happens again, I'll use better tools. But otherwise it's probably not a real bug in Twisted.

comment:11 Changed 5 years ago by ivank

Er, nevermind, I can replicate the crash. I'll look a bit more.

comment:12 Changed 5 years ago by glyph

  • Owner changed from glyph to ivank

comment:13 Changed 4 years ago by ivank

  • Summary changed from t.i.utils._callProtocolWithDeferred passes full executable path as first argument to Some Flash Player installers may crash on XP when launched by Twisted

Unfortunately, I have not looked into this, but I am changing the summary to reflect the actual problem I had. I still have no reason to believe there is definitely a Twisted bug.

comment:14 Changed 4 years ago by ivank

For what it's worth, the installer was the flashplayer9r159_winax.exe (non-debug installer). It only crashed on XP SP3 32-bit with IE7 installed. On nearly identical virtual machines with IE6 and IE8, the installer did not crash. I suspect something about the process environment caused the crashes, possibly something as crazy as the size of the environmental variables.

Changed 4 years ago by ivank

screenshot of crash

comment:15 Changed 4 years ago by ivank

  • Resolution set to invalid
  • Status changed from new to closed

I found that someone had an identical problem, even down to VMWare being used, and the faulting address in nsisarray.dll

"I have been distributing flash player 9.0.124 in a company" http://www.appdeploy.com/messageboards/tm.asp?m=37341

And of course, they were not using Twisted. I am closing this bug because there's no indication that Twisted should change how it launches programs on Windows. It might be the case that Adobe had a lucky coincidence where their installers actually worked when double-clicked in Explorer.

Note: See TracTickets for help on using tickets.