Indeed, it appears to be happening precisely upon return of an AV* from C space to Perl. Unfortunately it's a rather long function, but here's the relevant code (initializations and returns):
AV* segfaultingfunc( SV* obj1, SV* obj2 ){ { int dx_len = BIG_ENOUGH_NUMBER; int px_len = BIG_ENOUGH_NUMBER; SV* dxSV = newSVpvn(" ", 1); SV* pxSV = newSVpvn(" ", 1); char* dx_result = SvGROW( dxSV, dx_len ); char* px_result = SvGROW( pxSV, px_len ); int df, cf, lastdoc; // Here, in between, // dx_result and px_result get modified according to the contents of // obj1 and obj2, which contain strings of variable length. // dx_len and px_len are set to the true length of dx_result and px_result // Also, df, cf, and lastdoc are set. // set the true length of the strings in these SV SvCUR_set(dxSV, dx_len); SvCUR_set(pxSV, px_len); AV* array = newAV(); av_push(array, newSViv(df)); av_push(array, newSViv(cf)); av_push(array, dxSV); av_push(array, pxSV); av_push(array, newSViv(lastdoc)); av_push(array, newSViv(corpus_size - lastdoc)); // everything's fine up to this point, then seg fault occurs // before caller can continue! return array; } If I run it under the debugger, everything seems fine. The lengths and strings all add up, no overflows to be seen. The strings inside dxSV and pxSV never are overflowed because SVGROW makes them more than long enough to contain what's put there. Anyway, if this rings a bell, let me know. Cheers guys! -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, April 27, 2006 7:49 AM To: Ira Woodhead; inline@perl.org Subject: RE: segfaults and the perl debugger Yeah, I've seen this before, and it's very aggrivating. Probably has nothing to do with Inline, just C and perl. I'm guessing memory is just being initialized differently when you're running under the debugger. My only suggestion is to insert print statements and try again. =/ -Ken > -----Original Message----- > From: Ira Woodhead [mailto:[EMAIL PROTECTED] > Sent: Thursday, April 27, 2006 9:39 AM > To: inline@perl.org > Subject: segfaults and the perl debugger > > Hi guys, > > I'm working with Inline C and I have a segmentation fault > that occurs in certain easily reproduced conditions. I can't > seem to get any more specific error messages (such as where > the damn thing is happening) because when I put it into the > debugger, it doesn't happen! Everything seems to work > correctly if I simply call with -d and hit 'c' for continue. > > Anyone seen this? Is this a clue to something? > > Cheers! > > > PS: Happens on both linux x86 and intel macosx. I'm not that > bothered yet so I won't paste the pages of version info I > know I should. I'm just idly wondering if someone's seen this > kind of thing before. > > -------------------------------------------------------- > > -------------------------------------------------------- > > > > ATTENTION: DO NOT read, copy or disseminate this > communication unless you are the intended addressee. This > message and any file(s) or attachment(s) transmitted with it > are confidential, intended only for the named recipient, and > may contain information that is a trade secret, proprietary, > protected by the attorney work product doctrine, subject to > the attorney-client privilege, or is otherwise protected > against unauthorized use or disclosure. This message and any > file(s) or attachment(s) transmitted with it are transmitted > based on a reasonable expectation of privacy consistent with > ABA Formal Opinion No. 99-413. If you have received this > communication in error, please e-mail the sender and notify > the sender immediately that you have received the > communication in error. Thank you. > -------------------------------------------------------- -------------------------------------------------------- ATTENTION: DO NOT read, copy or disseminate this communication unless you are the intended addressee. This message and any file(s) or attachment(s) transmitted with it are confidential, intended only for the named recipient, and may contain information that is a trade secret, proprietary, protected by the attorney work product doctrine, subject to the attorney-client privilege, or is otherwise protected against unauthorized use or disclosure. This message and any file(s) or attachment(s) transmitted with it are transmitted based on a reasonable expectation of privacy consistent with ABA Formal Opinion No. 99-413. If you have received this communication in error, please e-mail the sender and notify the sender immediately that you have received the communication in error. Thank you.