Issue1312

classification
Title: pyftpdlib test suite failures
Type: Severity: normal
Components: Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amak, billiejoex, kfitch42, pjenvey
Priority: normal Keywords:

Created on 2009-04-09.02:46:43 by billiejoex, last changed 2009-07-12.00:51:52 by pjenvey.

Files
File name Uploaded Description Edit Remove
test_ftpd-cpython.txt kfitch42, 2009-04-15.14:57:16
test_ftpd-jython.txt kfitch42, 2009-04-15.15:01:01
hs_err_pid6933.log billiejoex, 2009-04-17.11:35:17
Messages
msg4492 (view) Author: Giampaolo Rodola' (billiejoex) Date: 2009-04-09.02:46:39
I'm trying to make pyftpdlib work on Jython but I'm encountering a bunch
of apparently weird problems.
When I run the test suite I get the following two errors.
The first one:

Exception in thread Thread:Traceback (most recent call last):
  File "/home/user/jython/Lib/threading.py", line 247, in _Thread__bootstrap
    self.run()
  File "test_ftpd.py", line 1998, in run
    self.server.serve_forever(timeout=self.__timeout, count=1,
  File "/home/user/jython/bin/ftpserver.py", line 3164, in serve_forever
    poll_fun(timeout, map)
  File "/home/user/jython/Lib/asyncore.py", line 121, in poll
    r, w, e = select.select(r, w, e, timeout)
  File "/home/user/jython/Lib/asyncore.py", line 121, in poll
    r, w, e = select.select(r, w, e, timeout)
  File "/home/user/jython/Lib/select.py", line 185, in native_select
    results = pobj.poll(timeout)
  File "/home/user/jython/Lib/select.py", line 134, in poll
    for k in selectedkeys.iterator():
  File "/home/user/jython/Lib/select.py", line 134, in poll
    for k in selectedkeys.iterator():
OutOfMemoryError: java.lang.OutOfMemoryError: Java heap space


The second one:

# An unexpected error has been detected by Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0xb7fb73a2, pid=7275, tid=3034299280
#
# Java VM: Java HotSpot(TM) Client VM (11.0-b15 mixed mode, sharing
linux-x86)
# Problematic frame:
# C  [ld-linux.so.2+0xe3a2]
#
# An error report file with more information is saved as:
# /home/user/jython/bin/hs_err_pid7275.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
./jython: line 216:  7275 Aborted                 "${JAVA_CMD[@]}"
$JAVA_OPTS "${java_args[@]}" -Dpython.home="$JYTHON_HOME"
-Dpython.executable="$PRG" org.python.util.jython $JYTHON_OPTS "$@"


Run on Ubuntu 8.04, JSE 1.6.0_10-b33, Jython 2.5b3
msg4493 (view) Author: Philip Jenvey (pjenvey) Date: 2009-04-09.04:19:15
You should be able to get around it with more memory. Try running jython 
with -J-Xmx512m

Prioritzing this as high because I was meaning to bump our default Xmx to 
512 anyway
msg4494 (view) Author: Philip Jenvey (pjenvey) Date: 2009-04-09.04:19:55
The latter crash is hopefully symptomatic of the memory problem -- 
otherwise, the JVM just isn't supposed to crash =]
msg4496 (view) Author: Giampaolo Rodola' (billiejoex) Date: 2009-04-09.12:28:18
It's exactly the same with -J-Xmx512m option.
msg4498 (view) Author: Philip Jenvey (pjenvey) Date: 2009-04-10.00:00:54
Does any more memory help i.e. -J-Xmx1024m? I somewhat doubt your test 
suite really needs this much though -- maybe we have a leak somewhere
msg4510 (view) Author: Kevin Fitch (kfitch42) Date: 2009-04-15.03:41:35
On a side note: did you tweak anything to deal with the partial support
for ipv6. I get an assertion failure:
Traceback (most recent call last):
  File "test/test_ftpd.py", line 94, in <module>
    SUPPORTS_IPV6 = socket.has_ipv6 and try_address('::1',
family=socket.AF_INET6)
  File "test/test_ftpd.py", line 85, in try_address
    s = socket.socket(family, socket.SOCK_STREAM)
  File "test/test_ftpd.py", line 85, in try_address
    s = socket.socket(family, socket.SOCK_STREAM)
  File "/home/kfitch/jython/dist/Lib/socket.py", line 1070, in __init__
    _sock = _realsocket(family, type, proto)
  File "/home/kfitch/jython/dist/Lib/socket.py", line 549, in _realsocket
    assert family == AF_INET, "Only AF_INET sockets are currently
supported on jython"
AssertionError: Only AF_INET sockets are currently supported on jython


See Issue1210.
msg4512 (view) Author: Kevin Fitch (kfitch42) Date: 2009-04-15.04:00:04
So I set SUPPORTS_IPV6=False so I could try to reproduce this. Then when
I run the test suite:
cd pyftpdlib-0.5.1;jython test/test_ftpd.py 
I get numerous errors such as:
test_rein_during_transfer (__main__.TestFtpAuthentication) ... Traceback
(most recent call last):
  File "__pyclasspath__/pyftpdlib/ftpserver.py", line 1957, in push_dtp_data
  File "__pyclasspath__/pyftpdlib/ftpserver.py", line 894, in
push_with_producer
  File "__pyclasspath__/pyftpdlib/ftpserver.py", line 923, in initiate_send
  File "__pyclasspath__/pyftpdlib/ftpserver.py", line 923, in initiate_send
NameError: global name 'buffer' is not defined

ERROR
msg4514 (view) Author: Giampaolo Rodola' (billiejoex) Date: 2009-04-15.08:53:15
You can solve that by getting the latest pyftpdlib revision from the SVN
repository:
http://code.google.com/p/pyftpdlib/source/checkout
msg4515 (view) Author: Kevin Fitch (kfitch42) Date: 2009-04-15.14:40:37
So I checked out the latest code, and the 'buffer' issue is gone, but I
still had to tweak SUPPORTS_IPV6 to get it to run. Also, the test suite
does not pass under CPython. The first thing that jumped out at me is
that it is checking for equality of floating point numbers, generally a
BIG no-no. In particular since, at a glance, those numbers are related
to something called 'CallLater'. Usually when scheduling something in
the future you can only so it will happen no-sooner-than, not exactly at.

That being said, I see nothing like what was described in the original
bug report. To be honest, my best guess is that this is actually a
hardware issue (bad ram?) or perhaps a currupted disk ... since the JVM
"shouldn't" crash.
msg4516 (view) Author: Giampaolo Rodola' (billiejoex) Date: 2009-04-15.14:46:25
> the 'buffer' issue is gone, but I still had to 
> tweak SUPPORTS_IPV6 to get it to run

Yes, I left it that way since I've noticed there's a bug already opened
for that on Jython issue tracker. 

> Also, the test suite does not pass under CPython

This is strange. Have you updated *also* test_ftpd.py to the latest
revision?
msg4517 (view) Author: Kevin Fitch (kfitch42) Date: 2009-04-15.14:57:15
CPython 2.5.2 on Ubuntu 8.04 x64

I am at pyftpdlib r586 (the only mod is setting the IPv6 thing to false)
msg4518 (view) Author: Kevin Fitch (kfitch42) Date: 2009-04-15.15:01:01
Latest jython from svn r6228
msg4522 (view) Author: Giampaolo Rodola' (billiejoex) Date: 2009-04-16.19:25:23
I'm not getting any failure. Maybe it's because I'm on a 32 bit sistem.
Could you please open a new issue on the pyftpdlib tracker?
http://code.google.com/p/pyftpdlib/issues/list
msg4523 (view) Author: Giampaolo Rodola' (billiejoex) Date: 2009-04-17.11:35:16
I realize I haven't answered some questions which have been asked to me.

> Does any more memory help i.e. -J-Xmx1024m? I somewhat 
> doubt your test  suite really needs this much though 
> -- maybe we have a leak somewhere

Tried with 1024 and also with 2048. Nothing changed.

> To be honest, my best guess is that this is actually a
> hardware issue (bad ram?) or perhaps a currupted disk 
> ... since the JVM "shouldn't" crash.

I'm running the tests on a virtualized Linux Ubuntu Server 8.04.
My actual workstation has 1.5 Gb of ram installed, the virtualized one
has 256 Mb reserved but it's a very minimal Ubuntu installation so I'm
sure it's not running out of memory.
I don't think I have any corrupted ram slot or physical drive issue.

The pyftpdlib related issues raised by Kevin should now be fixed in the
latest pyftpdlib SVN revision.

I'm attaching the log file generated by Jython when it crashes. Hope it
helps.
msg4524 (view) Author: Kevin Fitch (kfitch42) Date: 2009-04-17.14:36:30
With the new changes to pyftpdlib things are better. I get two errors:

======================================================================
ERROR: test_permit_privileged_ports (__main__.TestConfigurableOptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/test_ftpd.py", line 1675, in test_permit_privileged_ports
    socket.getservbyport(port)
  File "test/test_ftpd.py", line 1675, in test_permit_privileged_ports
    socket.getservbyport(port)
  File "/home/kfitch/projects/jython/dist/Lib/socket.py", line 541, in
getservbyport
    raise NotImplementedError("getservbyport not yet supported on jython.")
NotImplementedError: getservbyport not yet supported on jython.

======================================================================
FAIL: test_dele (__main__.TestFtpFsOperations)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/test_ftpd.py", line 871, in test_dele
    self.assertRaises(ftplib.error_perm, self.client.delete, self.tempdir)
AssertionError: error_perm not raised

----------------------------------------------------------------------
Ran 94 tests in 24.557s

FAILED (failures=1, errors=1)
msg4525 (view) Author: Kevin Fitch (kfitch42) Date: 2009-04-17.15:01:17
256MB is not very much. Java LOVES RAM, Python LOVES RAM ... put the two
together and ... well 256 probably isn't going to cut the mustard.

can you run

free -s 0.25 

In another terminal while you run the tests. On my box the amount of
free memory drops from ~274MB down to as low as ~24MB during the run ...
so it looks like it really wants about 250MB to run! So a box with only
256MB of RAM is going to have a tough time running this test.
msg4527 (view) Author: Giampaolo Rodola' (billiejoex) Date: 2009-04-17.15:54:45
It's surprising Jython uses so much memory!
With cPython the test suite uses 20 Mb at most.
Anyway, I bumped up the VMWare memory to 1028 Mb but the problem persists.
I ran free -s 0.25 in another terminal and noticed that I never run out
of free memory.

It seems that the problem might be somewhat related with the memory
since it appears only after a certain amount of time but I would say
that 1Gb of physical memory should be more than enough for this.
msg4544 (view) Author: Alan Kennedy (amak) Date: 2009-04-19.15:52:10
[billiejoex]
> It's surprising Jython uses so much memory!
> With cPython the test suite uses 20 Mb at most.
> Anyway, I bumped up the VMWare memory to 1028 Mb but the problem persists.

Are you sure that your "buffer" implementation is memory eficient?

Cpython's buffer implementation is efficient. But jython does not
support buffer. The "mock" version of buffer that you are using may
perhaps be causing the memory problem?
msg4545 (view) Author: Giampaolo Rodola' (billiejoex) Date: 2009-04-19.16:13:31
I got rid of my own "mock" buffer implementation in r572:
http://code.google.com/p/pyftpdlib/source/detail?r=572#
msg4584 (view) Author: Philip Jenvey (pjenvey) Date: 2009-04-24.02:20:38
I was able to run through the entire test_ftpd (pyftpdlib r599/jython 
r6258) without any memory issues. Java used about 150MB of memory max. 
This was on OS X 64 bit Java 6

Output here:

http://pylonshq.com/pasties/ed53e91bc7ded8c93d3c8cf7be3281f7

If you're still seeing OOM errors I'm inclined to point the finger at 
your version of Java. Can you try the tests elsewhere?
msg4896 (view) Author: Philip Jenvey (pjenvey) Date: 2009-07-12.00:51:51
It's been a while since any activity on this and the tests do run now, 
so I'm closing this out.

It looks like there are some other issues encountered in the test run 
but those should be narrowed down and have separate, specific bugs 
logged for them
History
Date User Action Args
2009-07-12 00:51:52pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg4896
2009-04-24 02:20:38pjenveysetpriority: high -> normal
messages: + msg4584
2009-04-19 16:13:32billiejoexsetmessages: + msg4545
2009-04-19 15:52:10amaksetnosy: + amak
messages: + msg4544
2009-04-17 15:54:45billiejoexsetmessages: + msg4527
2009-04-17 15:01:17kfitch42setmessages: + msg4525
2009-04-17 14:36:31kfitch42setmessages: + msg4524
2009-04-17 11:35:18billiejoexsetfiles: + hs_err_pid6933.log
messages: + msg4523
2009-04-16 19:25:23billiejoexsetmessages: + msg4522
2009-04-15 15:01:02kfitch42setfiles: + test_ftpd-jython.txt
messages: + msg4518
2009-04-15 14:57:17kfitch42setfiles: + test_ftpd-cpython.txt
messages: + msg4517
2009-04-15 14:46:27billiejoexsetmessages: + msg4516
2009-04-15 14:40:38kfitch42setmessages: + msg4515
2009-04-15 08:53:15billiejoexsetmessages: + msg4514
2009-04-15 04:00:04kfitch42setmessages: + msg4512
2009-04-15 03:41:35kfitch42setnosy: + kfitch42
messages: + msg4510
2009-04-10 00:00:56pjenveysetmessages: + msg4498
2009-04-09 12:28:19billiejoexsetmessages: + msg4496
2009-04-09 04:19:55pjenveysetmessages: + msg4494
2009-04-09 04:19:16pjenveysetpriority: high
nosy: + pjenvey
messages: + msg4493
2009-04-09 02:46:43billiejoexcreate