[erlang-questions] driver_async invoke leads to a segmentation fault

Niranjan Gunasekera niranjan@REDACTED
Fri Dec 22 04:06:06 CET 2006


Hi all,

    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?

 

Is it a problem with coding?

 

static int control(ErlDrvData drv_data, unsigned int command, char *buf, int len, char **rbuf, int rlen)

{

--------

            --------

            DriverData *dd = (DriverData *) drv_data;

            set_port_control_flags(dd->port, PORT_CONTROL_FLAG_BINARY);

            ThreadData *threadData;

            if((threadData = (ThreadData *) driver_alloc(sizeof(ThreadData))) == NULL) {

                        error = 1;

            }

            else {

                        error = 0;

                        memset(threadData, 0, sizeof(threadData));

                        if((threadData->input = (char *) driver_alloc(len + 1)) == NULL) {

                                    free(threadData);

                                    error = 1;

                        }

                        else {

                                    ---------

                                    ---------

                                    driver_async(dd->port, NULL, callTextToSpeech, (void *)threadData, freeThreadData);  //first call to this function works fine

                        }

            }

 

            }

            if (error)

                        gen_error_reply(rbuf, rlen, &rindex, "driver_alloc_failiure", 0);

            else

                        gen_ok_reply(rbuf, rlen, &rindex);

}

 

Thanks

Niranjan Gunasekera
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20061222/03e6423d/attachment.htm>


More information about the erlang-questions mailing list