{"action":"opened","issue":{"url":"https://api.github.com/repos/IssueMigrationTest/Test5/issues/112","labels_url":"https://api.github.com/repos/IssueMigrationTest/Test5/issues/112/labels{/name}","comments_url":"https://api.github.com/repos/IssueMigrationTest/Test5/issues/112/comments","events_url":"https://api.github.com/repos/IssueMigrationTest/Test5/issues/112/events","html_url":"https://github.com/IssueMigrationTest/Test5/issues/112","id":65106654,"number":112,"title":"Segfault in generated code - may be related to user-defined __len__","user":{"login":"ShedskinBot","id":11687421,"avatar_url":"https://avatars.githubusercontent.com/u/11687421?v=3","gravatar_id":"","url":"https://api.github.com/users/ShedskinBot","html_url":"https://github.com/ShedskinBot","followers_url":"https://api.github.com/users/ShedskinBot/followers","following_url":"https://api.github.com/users/ShedskinBot/following{/other_user}","gists_url":"https://api.github.com/users/ShedskinBot/gists{/gist_id}","starred_url":"https://api.github.com/users/ShedskinBot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ShedskinBot/subscriptions","organizations_url":"https://api.github.com/users/ShedskinBot/orgs","repos_url":"https://api.github.com/users/ShedskinBot/repos","events_url":"https://api.github.com/users/ShedskinBot/events{/privacy}","received_events_url":"https://api.github.com/users/ShedskinBot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/IssueMigrationTest/Test5/labels/auto-migrated","name":"auto-migrated","color":"ededed"},{"url":"https://api.github.com/repos/IssueMigrationTest/Test5/labels/Priority-Medium","name":"Priority-Medium","color":"ededed"},{"url":"https://api.github.com/repos/IssueMigrationTest/Test5/labels/Type-Defect","name":"Type-Defect","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-29T23:24:43Z","updated_at":"2015-03-29T23:24:43Z","closed_at":null,"body":"**Issue by na...@animats.com**\n_10 Nov 2010 at 4:50 GMT_\n_Originally opened on Google Code_\n\n----\n\n```\nWhat steps will reproduce the problem?\n1. Fix lib per issue 111.\n2. shedskin rfc822.py\n3. make\n4. ./rfc822.exe junk.txt\n\nWhat is the expected output? What do you see instead?\n\n$ ./rfc822.exe junk.txt\nFrom: (None, None)\nTo: []\nSubject: None\nDate: None\nSegmentation fault (core dumped)\n\n\nThis program parses mail headers, and it works correctly if run on\nthe provided file \"dummyinbox.txt\".  But if run on \"junk.txt\", it segfaults.  \nThe problem seems to be related to the code for a user-defined\n\"__len__\" function.  \n\nBuilding a debug version and running under GDB provides some insight:\n\nnagle@user-PC ~/work\n$ gdb rfc822_debug.exe\nGNU gdb 6.8.0.20080328-cvs (cygwin-special)\nCopyright (C) 2008 Free Software Foundation, Inc.\nLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\nThis GDB was configured as \"i686-pc-cygwin\"...\n(gdb) run junk.txt\nStarting program: /home/nagle/work/rfc822_debug.exe junk.txt\n[New thread 3712.0x85c]\nError: dll starting at 0x776f0000 not found.\nError: dll starting at 0x76e80000 not found.\nError: dll starting at 0x776f0000 not found.\nError: dll starting at 0x775f0000 not found.\n[New thread 3712.0xdb4]\nFrom: (None, None)\nTo: []\nSubject: None\nDate: None\n\nProgram received signal SIGSEGV, Segmentation fault.\n__rfc822__::__init () at \n/home/nagle/shedskin/shedskin-0.6/shedskin/lib/builtin.hpp:1721\n1721    template<class T> inline __ss_int len(T x) { return x->__len__(); }\n(gdb) backtrace\n#0  __rfc822__::__init () at \n/home/nagle/shedskin/shedskin-0.6/shedskin/lib/builtin.hpp:1721\n#1  0x00413fa8 in __shedskin__::__start (initfunc=0x4044b0 \n<__rfc822__::__init()>)\n    at /home/nagle/shedskin/shedskin-0.6/shedskin/lib/builtin.cpp:2082\n#2  0x004015cb in main (argc=1629157965, argv=0x0) at rfc822.cpp:935\n(gdb) frame\n#0  __rfc822__::__init () at \n/home/nagle/shedskin/shedskin-0.6/shedskin/lib/builtin.hpp:1721\n1721    template<class T> inline __ss_int len(T x) { return x->__len__(); }\n\nThe Python code applies \"len\" to an object, intending to invoke the object's \n\"__len__\" function.  Something may have gone wrong there.  I suspect a \nde-reference of NULL, but I don't see it in the C++ code yet.\n\n\n\n\n\nWhat version of the product are you using? On what operating system?\n\nShed Skin 0.6, Cygwin, \n\n\nPlease provide any additional information below.\n\nIf you run\n\n./rfc822.exe dummyinbox.txt\n\nwhich runs the program on a valid inbox file, it works.  So the code is correct \nfor the normal case, but some error case is failing. \n\n\n```\n\n\n\nAttachments:\n* [rfc822.py](https://storage.googleapis.com/google-code-attachments/shedskin/issue-112/comment-0/rfc822.py)\n* [rfc822date.py](https://storage.googleapis.com/google-code-attachments/shedskin/issue-112/comment-0/rfc822date.py)\n* [junk.txt](https://storage.googleapis.com/google-code-attachments/shedskin/issue-112/comment-0/junk.txt)\n* [dummyinbox.txt](https://storage.googleapis.com/google-code-attachments/shedskin/issue-112/comment-0/dummyinbox.txt)\n\n"}}