[M3devel] Problem interfacing C lib

Dragiša Durić dragisha at m3w.org
Tue Mar 20 07:04:58 CET 2012


Errorr is SIGSEGV.

chars is UNTRACED REF ARRAY OF CHAR but it is lesser problem, I think. It looks like  formal 'what' is not sent at all!? It's place is taken by next argument - INTEGER len (equal 0x7 in this example).

One common problem I meet often (as I bind C often :) is this - address of open array argument is ot what it looks like. To be sure you are getting address of various UNTRACED REF..ARRAY.. and open array procedure arguments - use 

ADR(chars[0])

and do not use:

LOOPHOLE(chars, ADDRESS)

Of course, I tried ADR(chars[0]) :) - Same thing happened. Right now II downgraded my code to use strstr(3), but this argument passing still bugs me.

dd


On Mar 20, 2012, at 1:26 AM, Mika Nystrom wrote:

> What are the declarations of all the variables involved in the call?
> 
> And what is the actual error?  Is it a SIGBUS, SIGSEGV?
> 
> =?utf-8?Q?Dragi=C5=A1a_Duri=C4=87?= writes:
>> I had some error before I LOOPHOLEd it.
>> 
>> On Mar 19, 2012, at 7:27 PM, Daniel Alejandro Benavides D. wrote:
>> 
>>> Hi all:
>>> if chars is ADDRESS type why are you LOOPHOLE'ing it?=20
>>> Thanks in advance
>>> =20
>>> --- El lun, 19/3/12, Dragi=C5=A1a Duri=C4=87 <dragisha at m3w.org> =
>> escribi=C3=B3:
>>> =20
>>>> De: Dragi=C5=A1a Duri=C4=87 <dragisha at m3w.org>
>>>> Asunto: [M3devel] Problem interfacing C lib
>>>> Para: "m3devel" <m3devel at elegosoft.com>
>>>> Fecha: lunes, 19 de marzo, 2012 12:13
>>>> #1  0x00000035bd8172a0 in
>>>> evbuffer_search_range (buffer=3D0x694090, what=3D0x7 <Address
>>>> 0x7 out of bounds>, len=3D0, start=3D0x0,
>>>> end=3D0x7fffffffdbb0)
>>>>   at buffer.c:2441
>>>> #2  0x0000000000404a0c in Buffer__Search (t=3D<error
>>>> reading variable>, pattern=3D<error reading
>>>> variable>, from=3D<error reading variable>,=20
>>>>   to=3D<error reading variable>) at
>>>> ../src/Buffer.m3:150
>>>> =20
>>>> Buffer.m3:150
>>>>       pos :=3D
>>>> evbuffer.search_range(t.b, LOOPHOLE(chars, ADDRESS), len,
>>>> NIL, NIL);
>>>> =20
>>>> t.b is a pointer, so is chars=E2=80=A6 len is Utypes.size_t and
>>>> it's value is 7.
>>>> =20
>>>> <* EXTERNAL evbuffer_search_range *>
>>>> PROCEDURE search_range(buf: t; what: char_star; len: size_t;
>>>> start, end: UNTRACED REF ptr): ptr;
>>>> =20
>>>> t is an ADDRESS, and so on=E2=80=A6
>>>> =20
>>>> Critical Mass Modula-3 version d5.9.0
>>>> last updated: 2010-07-21
>>>> compiled: 2010-10-04 07:24:16
>>>> configuration: /etc/cm3.cfg
>>>> host: AMD64_LINUX
>>>> target: AMD64_LINUX
>>>> =20
>>>> =20
>>>> Any ideas? TIA,
>>>> dd
>>>> =20
>>>> =20




More information about the M3devel mailing list