Ticket #10108 (needs_work defect)
Calling mwrank(-10) hangs Sage, but uses very little CPU time
| Reported by: | drkirkby | Owned by: | cremona |
|---|---|---|---|
| Priority: | major | Milestone: | sage-5.10 |
| Component: | elliptic curves | Keywords: | mwrank |
| Cc: | cremona | Work issues: | |
| Report Upstream: | N/A | Reviewers: | Mike Hansen |
| Authors: | John Cremona | Merged in: | |
| Dependencies: | Stopgaps: |
Description
Following some very quick hacks at using "fuzz testing" techniques, I found that
sage: mwrank(-10)
just hangs, but does not appear to be using any CPU time. Although I don't know what this is supposed to do, from discussions on sage-devel, I understand my suspicions this behavior is an error were correct.
Can someone please select the component appropriately, as I don't have a clue myself.
Attachments
Change History
comment:1 follow-up: ↓ 2 Changed 3 years ago by cremona
- Keywords mwrank added
- Owner changed from tbd to cremona
- Component changed from PLEASE CHANGE to elliptic curves
comment:2 in reply to: ↑ 1 Changed 3 years ago by cremona
Replying to cremona:
I have a patch for this which I will post soon.
Delays caused by break in internet access -- hope to post patch Sunday.
comment:3 follow-up: ↓ 4 Changed 3 years ago by cremona
- Status changed from new to needs_review
- Authors set to John Cremona
This was harder than expected. Without either (1) rewriting mwrank's in put parser or (2) writing a full parser within Sage and only sending to mwrank when certainly correct, which I do not want to do. If you feed mwrank correct but incomplete input (such as <5 integers separated by whitespace) it quietly waits for the rest of the input (with no prompts).
To get around this I pad the strings sent to mwrank with ' 0 0 0 0 0 ' which means that this never happens, and then to get repeated calls to mwrank to work properly need a bit of fiddling. I tested the patch on two machines (4.6.alpha3).
comment:4 in reply to: ↑ 3 Changed 3 years ago by drkirkby
Replying to cremona:
This was harder than expected. Without either (1) rewriting mwrank's in put parser or (2) writing a full parser within Sage and only sending to mwrank when certainly correct, which I do not want to do. If you feed mwrank correct but incomplete input (such as <5 integers separated by whitespace) it quietly waits for the rest of the input (with no prompts).
If this hard, then perhaps it's more effort to fix properly than it is worth. You are a better judge of that than me.
I can't help feeling if this is supposed to take 5 integers then it should take 5, and not accept fewer or more, as it does. For example:
sage: mwrank('1 2 3')
"Curve [0,0,0,1,2] : \n1 points of order 2:\n[-1:0:1]\n\nUsing 2-isogenous curve [0,6,0,-7,0] (minimal model [0,0,0,-19,30])\n-------------------------------------------------------\nFirst step, determining 1st descent Selmer groups\n-------------------------------------------------------\nAfter first local descent, rank bound = 0\nrk(S^{phi}(E'))= 1\nrk(S^{phi'}(E))= 1\n\n-------------------------------------------------------\nSecond step, determining 2nd descent Selmer groups\n-------------------------------------------------------\n...skipping since we already know rank=0\nAfter second local descent, rank bound = 0\nrk(phi'(S^{2}(E)))= 1\nrk(phi(S^{2}(E')))= 1\nrk(S^{2}(E))= 1\nrk(S^{2}(E'))= 2\n\nThird step, determining E(Q)/phi(E'(Q)) and E'(Q)/phi'(E(Q))\n-------------------------------------------------------\n1. E(Q)/phi(E'(Q))\n-------------------------------------------------------\n(c,d) =(-3,4)\n(c',d')=(6,-7)\nThis component of the rank is 0\n-------------------------------------------------------\n2. E'(Q)/phi'(E(Q))\n-------------------------------------------------------\nThis component of the rank is 0\n\n-------------------------------------------------------\nSummary of results:\n-------------------------------------------------------\n rank(E) = 0\n #E(Q)/2E(Q) = 2\n\nInformation on III(E/Q):\n #III(E/Q)[phi'] = 1\n #III(E/Q)[2] = 1\n\nInformation on III(E'/Q):\n #phi'(III(E/Q)[2]) = 1\n #III(E'/Q)[phi] = 1\n #III(E'/Q)[2] = 1\n\n\nUsed descent via 2-isogeny with isogenous curve E' = [0,0,0,-19,30]\nRank = 0\nRank of S^2(E) = 1\nRank of S^2(E') = 2\nRank of S^phi(E') = 1\nRank of S^phi'(E) = 1\n\nSearching for points (bound = 8)...done:\n found points of rank 0\n and regulator 1\nProcessing points found during 2-descent...done:\n now regulator = 1\nSaturating (bound = 100)...done:\n points were already saturated.\n\n\nRegulator = 1\n\nThe rank and full Mordell-Weil basis have been determined unconditionally.\n (0.055625 seconds)"
(It would also be nice if those \n's actually created a new line, as I expect they are supposed to do, but that's another issue entirely.)
Again, I don't feel able to review the Python.
comment:5 Changed 3 years ago by mhansen
- Status changed from needs_review to positive_review
- Reviewers set to Mike Hansen
Looks good to me. I added a patch which fixes the indentation of the options blocks.
comment:6 Changed 3 years ago by jdemeyer
- Status changed from positive_review to needs_work
Please fix the ticket number (10108, NOT 10105) in the patch
Changed 3 years ago by cremona
-
attachment
trac_10105-mwrank.patch
added
renamed version of previous -- applies to 4.6.rc0
comment:7 Changed 3 years ago by cremona
- Status changed from needs_work to needs_review
Apply only trac_10108-mwrank.3.patch (and sorry for the mess -- previous ones can be deleted).
Changed 3 years ago by jdemeyer
-
attachment
trac_10108-mwrank.4.patch
added
Ticket number fixed, apply only this patch
comment:8 follow-up: ↓ 9 Changed 3 years ago by jdemeyer
- Status changed from needs_review to positive_review
John, I seem to have confused you :-) Never mind, I made the fix myself.
comment:9 in reply to: ↑ 8 Changed 3 years ago by cremona
Replying to jdemeyer:
John, I seem to have confused you :-) Never mind, I made the fix myself.
Very sorry - -first I thought it was the patch's name, then the comment in the doctest... but at least the bugfix works!
comment:10 Changed 3 years ago by jdemeyer
- Status changed from positive_review to needs_work
This patch gives trouble for me when merging it as part of a potential sage-4.6.1.alpha0. For some reason I cannot explain, I get the following error when running sage -t devel/sage/sage/interfaces/mwrank.py:
sage -t "devel/sage/sage/interfaces/mwrank.py"
**********************************************************************
File "/mnt/usb1/scratch/jdemeyer/sage-4.6.1.alpha0-x86_64-Linux/devel/sage/sage/interfaces/mwrank.py", line 111:
sage: mwrank([0,-1,1,0,0])
Exception raised:
Traceback (most recent call last):
File "/mnt/usb1/scratch/jdemeyer/sage-4.6.1.alpha0-x86_64-Linux/local/bin/ncadoctest.py", line 1231, in run_one_test
self.run_one_example(test, example, filename, compileflags)
File "/mnt/usb1/scratch/jdemeyer/sage-4.6.1.alpha0-x86_64-Linux/local/bin/sagedoctest.py", line 38, in run_one_example
OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
File "/mnt/usb1/scratch/jdemeyer/sage-4.6.1.alpha0-x86_64-Linux/local/bin/ncadoctest.py", line 1172, in run_one_example
compileflags, 1) in test.globs
File "<doctest __main__.example_4[3]>", line 1, in <module>
mwrank([Integer(0),-Integer(1),Integer(1),Integer(0),Integer(0)])###line 111:
sage: mwrank([0,-1,1,0,0])
File "/mnt/usb1/scratch/jdemeyer/sage-4.6.1.alpha0-x86_64-Linux/local/lib/python/site-packages/sage/interfaces/mwrank.py", line 139, in __call__
raise ValueError, 'Invalid input (%s) to mwrank'%cmd
ValueError: Invalid input ([0, -1, 1, 0, 0]) to mwrank
**********************************************************************
What is strange is that simply doing
sage: mwrank([0,-1,1,0,0])
in a "real" Sage session works. So it works in Sage, but not in a doctest. I will need to investigate further.
comment:11 Changed 3 years ago by cremona
I think I can explain this. The problem to be solved for this ticket was that if mwrank is given incomplete but otherwise correct input, it just waits for the rest of the input, making Sage appear to hang. To fix this I made sure that the input provided by Sage always has some other stuff appended to it, so mwrank never has insufficient input. But then, the *next* time input is sent to mwrank, there is likely to be still some of that extra stuff in its input buffer. To get around that (I thought) I made sure that mwrank was restarted at every call.
Clearly what I did was insufficient, but this does explain who the order of executing commands does matter.

I have a patch for this which I will post soon.