<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns:o = "urn:schemas-microsoft-com:office:office"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Can anybody help, please</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks</FONT></DIV>
<DIV><FONT face=Arial size=2>Niranjan Gunasekera</FONT></DIV>
<DIV style="FONT: 10pt arial">----- Original Message -----
<DIV style="BACKGROUND: #e4e4e4; font-color: black"><B>From:</B> <A
title=niranjan@wavenet.lk href="mailto:niranjan@wavenet.lk">Niranjan
Gunasekera</A> </DIV>
<DIV><B>To:</B> <A title=erlang-questions@erlang.org
href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</A> </DIV>
<DIV><B>Sent:</B> Friday, December 22, 2006 9:06 AM</DIV>
<DIV><B>Subject:</B> [erlang-questions] driver_async invoke leads to a
segmentation fault</DIV></DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Hi all,</SPAN><SPAN
lang=EN-GB><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> I’m using erlang
driver_async to invoke a function asynchronously. First reference to the
function ‘driver_async’ works fine. But next reference to the same call leads to
a segmentation fault. I’m using erlang release R11B-2. Same code works fine with
erlang release R10B-10. Is it a problem with erlang
release?<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Is it a problem with
coding?<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">static int control(ErlDrvData
drv_data, unsigned int command, char *buf, int len, char **rbuf, int
rlen)<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">{<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">--------<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 1">
</SPAN>--------<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 1">
</SPAN>DriverData *dd = (DriverData *) drv_data;<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 1">
</SPAN>set_port_control_flags(dd->port,
PORT_CONTROL_FLAG_BINARY);<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 1">
</SPAN>ThreadData *threadData;<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 1">
</SPAN>if((threadData = (ThreadData *) driver_alloc(sizeof(ThreadData))) ==
NULL) {<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 2">
</SPAN>error = 1;<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 1">
</SPAN>}<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 1">
</SPAN>else {<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 2">
</SPAN>error = 0;<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 2">
</SPAN>memset(threadData, 0, sizeof(threadData));<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 2">
</SPAN>if((threadData->input = (char *) driver_alloc(len + 1)) == NULL)
{<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 3">
</SPAN>free(threadData);<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 3">
</SPAN>error = 1;<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 2">
</SPAN>}<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 2">
</SPAN>else {<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 3">
</SPAN>---------<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 3">
</SPAN>---------<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 3">
</SPAN><B style="mso-bidi-font-weight: normal">driver_async(dd->port, NULL,
callTextToSpeech, (void *)threadData, freeThreadData);<SPAN
style="mso-tab-count: 1"> </SPAN>//first call to this function works
fine<o:p></o:p></B></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 2">
</SPAN>}<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 1">
</SPAN>}<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 1">
</SPAN>}<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 1">
</SPAN>if (error)<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 2">
</SPAN>gen_error_reply(rbuf, rlen, &rindex, "driver_alloc_failiure",
0);<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 1">
</SPAN>else<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN
style="mso-tab-count: 2">
</SPAN>gen_ok_reply(rbuf, rlen, &rindex);<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><I
style="mso-bidi-font-style: normal"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">}<o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-GB><FONT
size=3><FONT face="Times New Roman"> <o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Thanks</SPAN><SPAN
lang=EN-GB><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-GB
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Niranjan Gunasekera</SPAN><SPAN
lang=EN-GB><o:p></o:p></SPAN></P></FONT></DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>erlang-questions
mailing
list<BR>erlang-questions@erlang.org<BR>http://www.erlang.org/mailman/listinfo/erlang-questions<BR></BODY></HTML>