Title: Fatal Python error: GC object already tracked · Issue #11 · timogasda/python-sqlparser · GitHub
Open Graph Title: Fatal Python error: GC object already tracked · Issue #11 · timogasda/python-sqlparser
X Title: Fatal Python error: GC object already tracked · Issue #11 · timogasda/python-sqlparser
Description: When using the library by running up and down the parse tree and extracting used columns and attributes of the parsed query I frequently ran into inexplicable errors and eventually into segmentation faults that crashed my python program....
Open Graph Description: When using the library by running up and down the parse tree and extracting used columns and attributes of the parsed query I frequently ran into inexplicable errors and eventually into segmentatio...
X Description: When using the library by running up and down the parse tree and extracting used columns and attributes of the parsed query I frequently ran into inexplicable errors and eventually into segmentatio...
Opengraph URL: https://github.com/timogasda/python-sqlparser/issues/11
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fatal Python error: GC object already tracked","articleBody":"When using the library by running up and down the parse tree and extracting used columns and attributes of the parsed query I frequently ran into inexplicable errors and eventually into segmentation faults that crashed my python program. When going for a proof of concept I ended with the following code that only works for me with iPython. However, I am pretty sure that the problem is not iPython but sqlparser as segmentation faults occurred on multiple occasions when using the library and when doing the proof of concept I was able to eliminate everything but sqlparser related code - however the overall error changed to the GC problem.\r\n\r\nI am using:\r\n- an Ubuntu 14.04\r\n- Python 2.7.6 (default, Oct 26 2016, 20:30:19)\r\n- IPython 1.2.1\r\n\r\nThe code:\r\n```\r\nimport sqlparser\r\n\r\ndef analyze_result_column_list(node):\r\n ret = []\r\n for subnode in node.list:\r\n if subnode.expr.leftOperand is not None:\r\n operand = subnode.expr.leftOperand\r\n for item in operand.caseExpression.whenClauseItemList:\r\n ret.append(item.comparison_expr.leftOperand.objectOperand.get_text())\r\n return ret\r\n\r\n\r\ndef analyze_select_statement(root):\r\n result_attributes = analyze_result_column_list(root.resultColumnList)\r\n return [], []\r\n\r\n\r\nclass SqlQuery():\r\n _query_string = None\r\n _defines = None\r\n _uses = None\r\n\r\n def __init__(self, stmt, vendor=sqlparser.gsp_dbvendor.dbvmysql):\r\n root = stmt.get_root()\r\n self._uses, self._defines = analyze_select_statement(root)\r\n\r\n\r\nparser = sqlparser.Parser()\r\nquery = \"SELECT (CASE WHEN password = MD5( 'bitnami ') THEN 1 ELSE 0 END) AS zend_auth_credential_match FROM si_user WHERE (email = 'user@example.com ')\"\r\nparser.check_syntax(query)\r\nstmt = parser.get_statement(0)\r\npq = SqlQuery(stmt)\r\npq._defines\r\npq._uses\r\nprint \"This was a triump,h \\nI make a note here: \\nHUGE SUCCESS.\"\r\n```\r\nRemoving `self._uses, self._defines = analyze_select_statement(root)` leads to the error not manifesting.\r\n\r\nThe bug can be recreated using a fresh virtual environment and then installing nothing but the sqlparser ,as described in the readme. Then do the following steps:\r\n1. activate the virtenv\r\n2. start IPython\r\n3. mark and copy the above code\r\n4. type %paste\r\n```\r\nPython 2.7.6 (default, Oct 26 2016, 20:30:19) \r\nType \"copyright\", \"credits\" or \"license\" for more information.\r\n\r\nIPython 1.2.1 -- An enhanced Interactive Python.\r\n? -\u003e Introduction and overview of IPython's features.\r\n%quickref -\u003e Quick reference.\r\nhelp -\u003e Python's own help system.\r\nobject? -\u003e Details about 'object', use 'object??' for extra details.\r\n\r\nIn [1]: %paste\r\nimport sqlparser\r\n\r\ndef analyze_result_column_list(node):\r\n ret = []\r\n for subnode in node.list:\r\n if subnode.expr.leftOperand is not None:\r\n operand = subnode.expr.leftOperand\r\n for item in operand.caseExpression.whenClauseItemList:\r\n ret.append(item.comparison_expr.leftOperand.objectOperand.get_text())\r\n return ret\r\n\r\n\r\ndef analyze_select_statement(root):\r\n result_attributes = analyze_result_column_list(root.resultColumnList)\r\n return [], []\r\n\r\n\r\nclass SqlQuery():\r\n _query_string = None\r\n _defines = None\r\n _uses = None\r\n\r\n def __init__(self, stmt, vendor=sqlparser.gsp_dbvendor.dbvmysql):\r\n root = stmt.get_root()\r\n self._uses, self._defines = analyze_select_statement(root)\r\n\r\n\r\nparser = sqlparser.Parser()\r\nquery = \"SELECT (CASE WHEN password = MD5( 'bitnami ') THEN 1 ELSE 0 END) AS zend_auth_credential_match FROM si_user WHERE (email = 'user@example.com ')\"\r\nparser.check_syntax(query)\r\nstmt = parser.get_statement(0)\r\npq = SqlQuery(stmt)\r\npq._defines\r\npq._uses\r\n\r\n## -- End pasted text --\r\nFatal Python error: GC object already tracked\r\nAborted (core dumped)\r\n```\r\n\r\nIf any additional feedback/versions/etc. are needed please notify me as I am happy to help in any way possible to get to the root of this issue.","author":{"url":"https://github.com/simkoc","@type":"Person","name":"simkoc"},"datePublished":"2017-05-30T18:46:44.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/11/python-sqlparser/issues/11"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:71e21915-decf-e221-911e-2f6153139b39 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AEE0:335FF6:AB0C853:DD16639:697F21AB |
| html-safe-nonce | 5823677c8240a2c500cf4ae7d4c253447dd6f778727c519809fecadb6af4a488 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRUUwOjMzNUZGNjpBQjBDODUzOkREMTY2Mzk6Njk3RjIxQUIiLCJ2aXNpdG9yX2lkIjoiNjM3MjA2NDgwNjk3NDcyNjU3MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 03649b422c581401e37710f3a72977314d54cd89f7b6d9fee2eb50c83fac4518 |
| hovercard-subject-tag | issue:232345694 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/timogasda/python-sqlparser/11/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7c63073c2b6da7fec7b87ff2ef85a147c48ddb800a0d0b520ad791f7310a6647/timogasda/python-sqlparser/issues/11 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7c63073c2b6da7fec7b87ff2ef85a147c48ddb800a0d0b520ad791f7310a6647/timogasda/python-sqlparser/issues/11 |
| og:image:alt | When using the library by running up and down the parse tree and extracting used columns and attributes of the parsed query I frequently ran into inexplicable errors and eventually into segmentatio... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | simkoc |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60279d4097367e16897439d16d6bbe4180663db828c666eeed2656988ffe59f6 |
| turbo-cache-control | no-preview |
| go-import | github.com/timogasda/python-sqlparser git https://github.com/timogasda/python-sqlparser.git |
| octolytics-dimension-user_id | 2446349 |
| octolytics-dimension-user_login | timogasda |
| octolytics-dimension-repository_id | 20052915 |
| octolytics-dimension-repository_nwo | timogasda/python-sqlparser |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20052915 |
| octolytics-dimension-repository_network_root_nwo | timogasda/python-sqlparser |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7c85641c598ad130c74f7bcc27f58575cac69551 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width