Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

#3781 closed defect (fixed)

Sometimes Trac install crashes on Windows at startup

Reported by: pkou at ua.fm Owned by: Christian Boos
Priority: high Milestone: 0.10
Component: general Version: 0.10rc1
Severity: critical Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Environment: Clean Trac install from source:/trunk@3787 on Windows XP and typical CGI configuration via Apache 2.0.55.

Problem: The system crashes while accessing Trac with the following details:

Oops...

Trac detected an internal error: 'module' object has no attribute 'fcntl'

Traceback (most recent call last):
  File "C:/Program Files/Apache Group/Apache2/cgi-bin/trac.cgi", line 20, in ?
    cgi_frontend.run()
  File "C:\Python23\Lib\site-packages\trac\web\cgi_frontend.py", line 55, in run
    flags = fcntl.fcntl(fd, fcntl.F_GETFL)
AttributeError: 'module' object has no attribute 'fcntl'

Reason: The specified place is protected from not existing modules using ImportError. However, it is not protected from the cases when the specific module exists but it does not have the required symbols.

Solution is proposed in the following patch:

  • trac/web/cgi_frontend.py

     
    5454            fd = stream.fileno()
    5555            flags = fcntl.fcntl(fd, fcntl.F_GETFL)
    5656            fcntl.fcntl(fd, fcntl.F_SETFL, flags & ~os.O_NONBLOCK)
    57     except ImportError:
     57    except (ImportError, AttributeError):
    5858        pass
    5959
    6060    try: # Use binary I/O on Windows
    6161        import msvcrt
    6262        msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
    6363        msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
    64     except ImportError:
     64    except (ImportError, AttributeError):
    6565        pass
    6666
    6767    gateway = CGIGateway()
  • trac/web/_fcgi.py

     
    948948                # Attempt to glean the maximum number of connections
    949949                # from the OS.
    950950                maxConns = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
    951             except ImportError:
     951            except (ImportError, AttributeError):
    952952                maxConns = 100 # Just some made up number.
    953953            maxReqs = maxConns
    954954            if multiplexed:

Attachments (0)

Change History (5)

comment:1 by Christian Boos, 18 years ago

Milestone: 0.10.10.10
Owner: changed from Jonas Borgström to Christian Boos
Status: newassigned

Looks good to me, except maybe the msvcrt one. It doesn't look like setmode can be missing if msvcrt can be imported…

comment:2 by Christian Boos, 18 years ago

Resolution: fixed
Status: assignedclosed

Fixed in r3790.

comment:3 by Matthew Good, 18 years ago

Keywords: needinfo added
Resolution: fixed
Status: closedreopened

The module fcntl should not be available on Windows. The docs specifically list "Availablility: Unix" for the module, not specific functions: http://docs.python.org/lib/module-fcntl.html

I just tested Python 2.3, 2.4, and 2.5 on Windows and this module is not available on any of these. So, I'd kind of like to know what's really going on here before we just throw on a patch.

comment:4 by Christian Boos, 18 years ago

Keywords: needinfo removed

Here's what I've found after some research:

From other references, it looks like some Windows 2.3 installations still have a fcntl.pyc in their Python23\Lib…

I think that r3790 doesn't "hurt" that much, and if it helps Trac to work out-of-the-box even on those "broken" installations, I'd say we should keep it.

in reply to:  4 comment:5 by Matthew Good, 18 years ago

Resolution: fixed
Status: reopenedclosed

Replying to cboos:

Here's what I've found after some research:

Ok, that seems like a good enough reason.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.