Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Strange crash while running a script with a embedded python interpreter Date: Mon, 11 Jan 2016 19:09:40 +1100 Lines: 37 Message-ID: References: <4ac97a67-2527-424e-90e2-b714528977c8@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de evVn7q6lCSHdmVS+FT4NiQ7YUQGAnETVIMvCQlk6RrqA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'compiler': 0.05; 'friday,': 0.07; 'incompatible': 0.07; 'interpreter.': 0.07; 'api': 0.09; 'cc:addr:python-list': 0.09; 'subject:script': 0.09; 'subject:while': 0.09; 'subtle': 0.09; 'wrong,': 0.09; 'python': 0.10; 'jan': 0.11; 'subject:python': 0.14; '(also': 0.16; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'msvcrt': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'should.': 0.16; 'sorts': 0.16; 'with?': 0.16; 'wrote:': 0.16; 'memory': 0.17; 'module,': 0.18; 'pointer': 0.18; 'settings': 0.20; 'windows': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'first,': 0.20; 'not,': 0.22; '3.x': 0.22; 'am,': 0.23; 'seems': 0.23; 'downloaded': 0.24; 'somewhere': 0.24; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; "i've": 0.25; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'idea': 0.28; 'values': 0.28; 'crash': 0.29; 'disabling': 0.29; 'expose': 0.29; 'creating': 0.30; 'code': 0.30; 'related': 0.32; 'compiled': 0.32; 'though,': 0.32; 'problem': 0.33; 'source': 0.33; 'michael': 0.33; 'though.': 0.33; 'info': 0.34; 'gets': 0.35; 'received:google.com': 0.35; 'trouble': 0.35; 'could': 0.35; 'something': 0.35; 'comment': 0.35; 'but': 0.36; 'project': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'modules': 0.36; 'projects.': 0.36; 'visual': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'itself': 0.38; 'january': 0.38; 'version': 0.38; 'received:209': 0.38; 'self': 0.38; 'several': 0.38; 'or,': 0.38; 'goes': 0.39; 'along': 0.39; 'build': 0.40; 'where': 0.40; 'subject:with': 0.40; 'still': 0.40; 'some': 0.40; 'your': 0.60; 'our': 0.64; 'led': 0.72; '2013)': 0.84; '3.5.1': 0.84; 'chrisa': 0.84; 'versions)': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=IgDfO74npxZap+1q8bzhccX59JOeDflmYpYW6/ox+yM=; b=fUq6/G+vjSUR0Bz7NXMMU75AdyDyw/qWj3XbgzGXcH205XWAeE5skHgW/OdXuU4T+f 1hZc3Y30W/TlrQSjgQ+42SghLaeeStgsqzqfnNV7Ui4pVvdhAWv1m7zUphyq/++FsQ6Z JI0ZXK+vnKS0wdltUhAUJHh4xyhgsb++HcgCWJAoVckjgFEMOc8AZXllegFd5hHZJZSQ q5g/iEynvwwRJFtVQZ9BR05lcvdJf95CjG2SddNkZ4y7e+MNKI6I1Wzs6Gyhq5MEzJVS 98qBBlLeQ4eSgk1q43zLMvAYlU3yDcRs73go1l2sJsr7gLqhvtI52d8G/35H48cqlLmD 9ofw== X-Received: by 10.50.70.38 with SMTP id j6mr10747482igu.13.1452499780148; Mon, 11 Jan 2016 00:09:40 -0800 (PST) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:101468 On Mon, Jan 11, 2016 at 6:55 PM, Rickard Englund wrote: > On Friday, January 8, 2016 at 11:28:53 PM UTC+1, Michael Torrie wrote: >> On 01/08/2016 09:18 AM, Rickard Englund wrote: >> > First, some system info >> > * Windows 7 (also tested on 8 and 10) >> > * Python 3.5.1 64bit (previously also tested using several 3.x version= s) (also tested with 32 bit, but with 3.4.2) >> > * Microsoft Visual Studio 2015 (earlier version of python also tested = with Visual Studio 2013) >> >> Are you using the same version of Visual Studio that Python itself was >> compiled with? If not there can be subtle problems with incompatible >> msvcrt dlls. No idea if this would be contributing to the problem or >> not, though. > > I've just downloaded the python source code and build it myself, the comp= iler settings in our project is the same as in the python projects. > > > Though, your comment led me in the correct direction. When using the libs= /binary I built my self it let me see the values of the PyObjects around th= e crash and it seems like it is related to our modules and/or how we expose= them to the interpreter. When disabling our own modules everything seems t= o be working as it should. > Interesting. So somewhere along the way, you have native code (C code?) that's creating a module, and that's where the trouble starts? I would first look at all your refcount management; if that goes wrong, all sorts of craziness could happen (if you still have a pointer to a block of memory that gets released and reused, hilarity will ensue - or, something will). Have you considered using Cython? That might let you do what you need without worrying about all those annoying internal API details. ChrisA