Re: [lxml] debugging seg fault in lxml.html.fromstring in pypy
![](https://secure.gravatar.com/avatar/54d44258067e7eb3077f82bb76b8927c.jpg?s=120&d=mm&r=g)
I've managed to narrow this down more to a test that reads a login form and sets 3 fields in that form. While this test completes fine on it's own, if it attempts to set any of those form fields, subsequent tests will generate a Seg Fault. The test calls a method to login in which I've commented out large portions of the functionality in order to narrow down the problematic operation. By a crude binary search of adding 'return True' to various locations in the method I was able to find the code that seemed crucial to controlling the occurance of Seg Faults. Below this code is a small excerpt of a stack trace resulting from the next test after this. def login(self, rd=None): """Login to the PACER court site""" if self._logged_in: return True login_url = urljoin(self._base_url, self.LOGIN_URL) log.debug("Logging in...") login_page = self._visit(login_url) log.debug("Got login form, pausing...") login_info = html.fromstring(login_page.text) login_form = login_info.forms[0] print ("login %s, key %s, clcode %s", self.user_name, self.user_password, self.CLIENT_CODE) form_fields = login_form.fields print ("login_form %s", list(form_fields.items())) #return True # THIS WORKS form_fields['login'] = self.user_name form_fields['key'] = self.user_password form_fields['clcode'] = self.CLIENT_CODE return True # THIS DOES NOT WORK """ login_form.fields = form_fields #return True log.debug("Submitting login: %s", login_form.form_values()) self._pause() #return True response = self.s.post(login_url, data=login_form.form_values(), cookies=self.cookies) self.load_cookies(response.content) self._show_receipts = True #2nd call to verify login resp = self.s.get(login_url, cookies=self.cookies) if 'Last login:' not in resp.content: raise PacerLoginException(login_url) self._logged_in = True self.last_response = resp if rd is not None: from bias.utils import save_pacer_cookies save_pacer_cookies(rd, self) return True """ A stack trace excerpt: test_case_tags (bias.tests.loaders.test_pacer.TestCaseLoader) ... *** glibc detected *** /home/jeff/lexmachina/deus_lex/.tox/pypy/bin/pypy /home/jeff/lexmachina/deus_lex/.tox/pypy/bin/nosetests -v -x bias: corrupted double-linked list: 0x0000000004c13eb0 *** ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x75be6)[0x7fe5e3fadbe6] /lib/x86_64-linux-gnu/libc.so.6(+0x7605d)[0x7fe5e3fae05d] /lib/x86_64-linux-gnu/libc.so.6(+0x77518)[0x7fe5e3faf518] /lib/x86_64-linux-gnu/libc.so.6(cfree+0x6c)[0x7fe5e3fb298c] /usr/lib/x86_64-linux-gnu/libxml2.so.2(xmlHashFree+0xfa)[0x7fe5dddab28a] /usr/lib/x86_64-linux-gnu/libxml2.so.2(xmlXPathRegisteredNsCleanup+0x1f)[0x7fe5dddd673f] /usr/lib/x86_64-linux-gnu/libxml2.so.2(xmlXPathFreeContext+0x22)[0x7fe5dddd99d2] /home/jeff/lxml/src/lxml/etree.pypy-26.so(+0x48049)[0x7fe5de546049]
participants (1)
-
Jeff Doran