[erlang-questions] R15B changes erl_driver API

438 views
Skip to first unread message

Sergei Golovan

unread,
Dec 15, 2011, 10:44:41 AM12/15/11
to erlang-q...@erlang.org
Hi!

Appears that erl_driver API has been changed in R15B. The following
change in erts/emulator/beam/erl_bif_ddll.c (R15B with respect to
R14B04)

-----------------------------------------------------------------------------------------
}

switch (dp->extended_marker) {
- case 0:
- /*
- * This may be an old driver that has been recompiled. If so,
- * at least the fields that existed in extended driver version
- * 1.0 should be zero. If not, a it is a bad driver. We cannot
- * be completely certain that this is a valid driver but this is
- * the best we can do with old drivers...
- */
- if (dp->major_version != 0
- || dp->minor_version != 0
- || dp->driver_flags != 0
- || dp->handle2 != NULL
- || dp->process_exit != NULL) {
- /* Old driver; needs to be recompiled... */
- return ERL_DE_LOAD_ERROR_INCORRECT_VERSION;
- }
- break;
case ERL_DRV_EXTENDED_MARKER:
if (ERL_DRV_EXTENDED_MAJOR_VERSION != dp->major_version
|| ERL_DRV_EXTENDED_MINOR_VERSION < dp->minor_version) {
-----------------------------------------------------------------------------------------

makes R15B return error "incorrect driver version" for so-called old
drivers (which don't initialize fields extended_marker, major_version
and minor_version in their ErlDrvEntry structure, or initialize them
as zeros).

As a consequence

1) documentation became incorrect (at least
http://www.erlang.org/doc/man/driver_entry.html where extended_marker
is still allowed to be 0);

2) example from http://www.erlang.org/doc/tutorial/c_portdriver.html
doesn't work anymore;

3) many existing applications break (YAWS and ejabberd definitely, I
suspect many others too, because example in tutorial don't use
extended_marker).

So, will this change be permanent (the documentation and all
applications are to be fixed), or this change will be considered too
disruptive and old drivers will be allowed back in R15B01?

(By the way, the error message is a bit misleading, especially after
the driver was recompiled using R15B.)

Cheers!
--
Sergei Golovan
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

Steve Vinoski

unread,
Dec 15, 2011, 11:46:07 AM12/15/11
to Sergei Golovan, erlang-q...@erlang.org
On Thu, Dec 15, 2011 at 10:44 AM, Sergei Golovan <sgol...@gmail.com> wrote:
>
> 3) many existing applications break (YAWS and ejabberd definitely, I
> suspect many others too, because example in tutorial don't use
> extended_marker).

Yaws is already fixed on master at github: https://github.com/klacke/yaws .

--steve

Kenneth Lundin

unread,
Dec 15, 2011, 12:38:39 PM12/15/11
to Sergei Golovan, erlang-q...@erlang.org


Den 15 dec 2011 16:45 skrev "Sergei Golovan" <sgol...@gmail.com>:
>
> Hi!
>
> Appears that erl_driver API has been changed in R15B. The following
> change in erts/emulator/beam/erl_bif_ddll.c (R15B with respect to
> R14B04)
>

This should be no surprise since it is clearly mentioned in the release highlights and in the Readme file. It is also in the documentation, but as you point out there might be some remaining issues there, thanks for that.
The change imicrotonal and will stay like this. We thought it was better to require the use of version number in drivers so that we can detect old drivers and refuse loading them, rather than just trying to run which might result in strange errors later during runtime.

> ----

...
/Kenneth, Erlang/OTP Ericsson

Sergei Golovan

unread,
Dec 15, 2011, 12:44:03 PM12/15/11
to erlang-q...@erlang.org
On Thu, Dec 15, 2011 at 9:38 PM, Kenneth Lundin
<kenneth...@gmail.com> wrote:
>>
> This should be no surprise since it is clearly mentioned in the release
> highlights and in the Readme file. It is also in the documentation, but as
> you point out there might be some remaining issues there, thanks for that.
> The change imicrotonal and will stay like this. We thought it was better to
> require the use of version number in drivers so that we can detect old
> drivers and refuse loading them, rather than just trying to run which might
> result in strange errors later during runtime.

I must've missed this in highlights. Ok then, lets fix the applications.

Zabrane Mickael

unread,
Dec 15, 2011, 1:32:31 PM12/15/11
to Kenneth Lundin, erlang-q...@erlang.org
Hi guys,

After installing R15B (OSX 10.6.8), this module no longer works for me:

I got the following error:
[...]
SUPERVISOR REPORT==== 15-Dec-2011::19:27:52 ===
     Supervisor: {local,reactiv_sup}
     Context:    start_error
     Reason:     {{badmatch,{error,"Error loading sqlite3_drv_darwin_64: Driver compiled with incorrect version of erl_driver.h"}},

The driver seems to include the MAJOR/MINOR markers:

Any Help?

Regards,
Zabrane

_______________________________________________

Sergei Golovan

unread,
Dec 15, 2011, 1:40:23 PM12/15/11
to Zabrane Mickael, erlang-q...@erlang.org
On Thu, Dec 15, 2011 at 10:32 PM, Zabrane Mickael <zabr...@gmail.com> wrote:
> Hi guys,
>
> After installing R15B (OSX 10.6.8), this module no longer works for me:
> https://github.com/alexeyr/erlang-sqlite3
>
> I got the following error:
> [...]
> SUPERVISOR REPORT==== 15-Dec-2011::19:27:52 ===
>      Supervisor: {local,reactiv_sup}
>      Context:    start_error
>      Reason:     {{badmatch,{error,"Error loading sqlite3_drv_darwin_64:
> Driver compiled with incorrect version of erl_driver.h"}},
>
> The driver seems to include the MAJOR/MINOR markers:
> https://github.com/alexeyr/erlang-sqlite3/blob/master/c_src/sqlite3_drv.c
>
> Any Help?

You must rebuild it with Erlang R15B to work.

Cheers!
--
Sergei Golovan

Zabrane Mickael

unread,
Dec 15, 2011, 1:39:33 PM12/15/11
to Sergei Golovan, erlang-q...@erlang.org
Of course, that's what I did first before posting this error.

Zabrane Mickael

unread,
Dec 16, 2011, 2:30:03 AM12/16/11
to Andrew Tunnell-Jones, Erlang-Questions Questions
Hi Andrew,

Works now ... may thanks.
I've also copied the package author.

Regards,
Zabrane

On Dec 16, 2011, at 7:39 AM, Andrew Tunnell-Jones wrote:

> On Fri, Dec 16, 2011 at 5:32 AM, Zabrane Mickael <zabr...@gmail.com> wrote:
>>
>> After installing R15B (OSX 10.6.8), this module no longer works for me:
>> https://github.com/alexeyr/erlang-sqlite3
>>
>> I got the following error:
>> [...]
>> SUPERVISOR REPORT==== 15-Dec-2011::19:27:52 ===
>> Supervisor: {local,reactiv_sup}
>> Context: start_error
>> Reason: {{badmatch,{error,"Error loading sqlite3_drv_darwin_64:
>> Driver compiled with incorrect version of erl_driver.h"}},
>>
>> The driver seems to include the MAJOR/MINOR markers:
>> https://github.com/alexeyr/erlang-sqlite3/blob/master/c_src/sqlite3_drv.c
>>
>> Any Help?
>>
>

> Line 27 should have ERL_DRV_EXTENDED_MINOR_VERSION in place of
> ERL_DRV_EXTENDED_MAJOR_VERSION.
>
> — Andrew

Alexey Romanov

unread,
Dec 16, 2011, 4:25:22 AM12/16/11
to Zabrane Mickael, Erlang-Questions Questions
D'oh! Thanks, fixed now.

Yours, Alexey Romanov

Sverker Eriksson

unread,
Dec 16, 2011, 8:46:43 AM12/16/11
to erlang-q...@erlang.org

> You must rebuild it with Erlang R15B to work.
>
Not just rebuild:

http://www.erlang.org/doc/man/erl_driver.html#rewrites_for_64_bits


/Sverker, Erlang/OTP

Alexey Romanov

unread,
Jan 25, 2012, 1:17:50 AM1/25/12
to Sverker Eriksson, erlang-q...@erlang.org
Thank you! I'll try to fix it this or next month, when I have time.

Yours, Alexey Romanov

Tony Rogvall

unread,
Jan 25, 2012, 8:23:46 AM1/25/12
to Alexey Romanov, erlang-q...@erlang.org

Hi I am doing some upgrades of drivers right now. I realized that I sometimes need to be able to
compile on pre R15 so I came up with the following scheme in drv_x.c:

#include "erl_driver.h"

// Hack to handle R15 driver used with pre R15 driver
#if ERL_DRV_EXTENDED_MAJOR_VERSION == 1
typedef int  ErlDrvSizeT;
typedef int  ErlDrvSSizeT;
#endif

Then I re-type x_ctl ...

I think this will work, at least for me ? Or will there be a 1.x that breaks this ?

/Tony
"Installing applications can lead to corruption over time. Applications gradually write over each other's libraries, partial upgrades occur, user and system errors happen, and minute changes may be unnoticeable and difficult to fix"



Raimo Niskanen

unread,
Jan 25, 2012, 8:57:57 AM1/25/12
to erlang-q...@erlang.org
On Wed, Jan 25, 2012 at 02:23:46PM +0100, Tony Rogvall wrote:
>
> Hi I am doing some upgrades of drivers right now. I realized that I sometimes need to be able to
> compile on pre R15 so I came up with the following scheme in drv_x.c:
>
> #include "erl_driver.h"
>
> // Hack to handle R15 driver used with pre R15 driver
> #if ERL_DRV_EXTENDED_MAJOR_VERSION == 1
> typedef int ErlDrvSizeT;
> typedef int ErlDrvSSizeT;
> #endif
>
> Then I re-type x_ctl ...
>
> I think this will work, at least for me ? Or will there be a 1.x that breaks this ?

No. Between major versions (going forward) it is supposed to suffice
with recompiling.

>
> /Tony
>
>
>
> On 25 jan 2012, at 07:17, Alexey Romanov wrote:
>
> > Thank you! I'll try to fix it this or next month, when I have time.
> >
> > Yours, Alexey Romanov
> >
> >
> >
> > On Fri, Dec 16, 2011 at 5:46 PM, Sverker Eriksson
> > <sve...@erix.ericsson.se> wrote:
> >>
> >>> You must rebuild it with Erlang R15B to work.
> >>>
> >>
> >> Not just rebuild:
> >>
> >> http://www.erlang.org/doc/man/erl_driver.html#rewrites_for_64_bits
> >>
> >>
> >> /Sverker, Erlang/OTP
> >>
> >>
> >>
> >> _______________________________________________
> >> erlang-questions mailing list
> >> erlang-q...@erlang.org
> >> http://erlang.org/mailman/listinfo/erlang-questions
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-q...@erlang.org
> > http://erlang.org/mailman/listinfo/erlang-questions
>
> "Installing applications can lead to corruption over time. Applications gradually write over each other's libraries, partial upgrades occur, user and system errors happen, and minute changes may be unnoticeable and difficult to fix"
>
>
>

> _______________________________________________
> erlang-questions mailing list
> erlang-q...@erlang.org
> http://erlang.org/mailman/listinfo/erlang-questions


--

/ Raimo Niskanen, Erlang/OTP, Ericsson AB

Reply all
Reply to author
Forward
0 new messages