<div dir="ltr">Your notes on debugging should help me out significantly. I had forgotten about the :c-file and other switches. I'll also read up on the UFFI interface and see if I can find where the bug lies. Thanks for the tips!<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 20, 2014 at 5:47 PM, Waldek Hebisch <span dir="ltr"><<a href="mailto:hebisch@math.uni.wroc.pl" target="_blank">hebisch@math.uni.wroc.pl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Andrew Lyon wrote:<br>
><br>
> Hey everyone (again). Since my last email, I found what appears to be a<br>
> weird CFFI/ECL bug. This was the cause of the problem I reported earlier<br>
> today. It seems like the code in the function runs fine, but on return it<br>
> barfs a segfault:<br>
><br>
> <a href="https://gist.github.com/orthecreedence/15dea89a0a7d591bba51" target="_blank">https://gist.github.com/orthecreedence/15dea89a0a7d591bba51</a><br>
><br>
> Note that I ended up working around this problem using ffi:c-inline to set<br>
> the values in the struct manually, but I consider this an ugly fix that I'd<br>
> rather not have there.<br>
><br>
> Any ideas on what's wrong? Thanks!<br>
<br>
Probably not the cause of your problem, but AFAICS you have wrong types<br>
in foreign calls: 'memset' needs 'size_t' as third (last) argument<br>
and you pass ':unsigned-char'. Similarly 'htons' has unsigned short<br>
as argument. 'htonl' need 32-bit unsigned integer as argument<br>
and returns 32-bit unsigned integer. On Windows 'long' gives<br>
right size, but on other systems long may be too big (long typically<br>
has 64-bits on non-Windows 64-bit systems).<br>
<br>
My method to debug such problem is to put Lisp source in a file and<br>
use :c-file :h-file :data-file keyword arguments to 'compile-file'<br>
to capture resulting C code. Then I look at C code to check if<br>
it is right -- that should localize the problem to specific plase.<br>
Once you know problem spot you may trace what 'cffi:with-foreign-slots'<br>
is doing and what wnet wrong.<br>
<br>
Note: native ecl FFI is UFFI and it allows you to assign to foreign<br>
data. So you may manually assign slots at UFFI level. I did not<br>
use CFFI but probably its constructs are translated (macro-expanded)<br>
to native (UFFI for ecl) constructs. In such case looking at UFFI<br>
translation you should be able to determine if ecl has bug in its<br>
implementation of UFFI or bug is in CFFI.<br>
<br>
--<br>
Waldek Hebisch<br>
<a href="mailto:hebisch@math.uni.wroc.pl">hebisch@math.uni.wroc.pl</a><br>
<br>
------------------------------------------------------------------------------<br>
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions<br>
Find What Matters Most in Your Big Data with HPCC Systems<br>
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.<br>
Leverages Graph Analysis for Fast Processing & Easy Data Exploration<br>
<a href="http://p.sf.net/sfu/hpccsystems" target="_blank">http://p.sf.net/sfu/hpccsystems</a><br>
_______________________________________________<br>
Ecls-list mailing list<br>
<a href="mailto:Ecls-list@lists.sourceforge.net">Ecls-list@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/ecls-list" target="_blank">https://lists.sourceforge.net/lists/listinfo/ecls-list</a><br>
</blockquote></div><br></div>