1 Aug 2011 11:53

### binary pattern matching fails with 32-bit float, if decimal representation of the number cannot be converted to binary exactly

```WHAT:
binary pattern matching fails with 32-bit float, if decimal
representation of the number cannot be converted to binary exactly

EXAMPLE:
following code fails:

% "1.1" does not have exact binary representation
> case <<1.1:32/float>> of <<1.1:32/float>> -> ok end.
** exception error: no case clause matching <<63,140,204,205>>

> case <<63,140,204,205>> of <<1.1:32/float>> -> ok end.
** exception error: no case clause matching <<63,140,204,205>>

although

> case <<1.1:32/float>> of <<63,140,204,205>> -> ok end.
ok

% "1.5" has exact binary representation
> case <<1.5:32/float>> of <<1.5:32/float>> -> ok end.
ok

% 64-bit floats work well
> case <<1.1:64/float>> of <<1.1:64/float>> -> ok end.
ok

--
З павагай, Вадзім Зенька
```

1 Aug 2011 12:06

### Re: binary pattern matching fails with 32-bit float, if decimal representation of the number cannot be converted to binary exactly

```
Compiling to BEAM ASM illustrates why:

>> case <<1.1:32/float>> of <<1.1:32/float>> -> ok end.
> ** exception error: no case clause matching <<63,140,204,205>>

{function, f, 0, 2}.
{label,1}.
{func_info,{atom,bin_match},{atom,f},0}.
{label,2}.
{move,{literal,<<63,140,204,205>>},{x,0}}.
{test,bs_start_match2,{f,3},1,[{x,0},0],{x,1}}.
{test,bs_get_float2,
{f,3},
2,
[{x,1},
{integer,32},
1,
{field_flags,[{anno,[6,{file,"./bin_match.erl"}]},unsigned,big]}],
{x,2}}.
{test,is_eq_exact,{f,3},[{x,2},{float,1.1}]}.
{test,bs_test_tail2,{f,3},[{x,1},0]}.
{move,{atom,ok},{x,0}}.
return.
{label,3}.
{case_end,{x,0}}.

The constructor pattern is evaluated at compile-time, so the binary appears in the ASM.
The match pattern uses the bit syntax operators to extract a float, and then checks the result (now using
native float representation) to the hard-coded float 1.1.
```

1 Aug 2011 12:09

### binary pattern matching fails with 32-bit float, if decimal representation of the number cannot be converted to binary exactly

```Version: Erlang 5.8.4/OTP R14B03

Sorry.

--

--
З павагай, Вадзім Зенька
+375.29.407.27.17
_______________________________________________
erlang-bugs mailing list
erlang-bugs <at> erlang.org
http://erlang.org/mailman/listinfo/erlang-bugs
```
9 Aug 2011 15:03

### Re: Bug when streaming input to xmerl_scan

```
Thanks Simon, your fix will be applied in R14B04.

Regards Lars
Erlang/OTP, Ericsson AB

On 07/27/2011 09:12 PM, Simon Cornish wrote:
> Consider the following trivial XML:
>
> <?xml version="1.0" ?>
> <item a="b">blah</item>
>
> If this is being fed to xmerl_scan:string via a continuation_fun and
> the current input runs out at the end of an attribute value (in this
> example, the 2nd " character on the item line) then it will crash.
> This is demonstrated in the small attached module.
> One possible fix that has been tested is also attached.
>
> Regards,
>   Simon
>
>
>
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs <at> erlang.org
> http://erlang.org/mailman/listinfo/erlang-bugs

_______________________________________________
erlang-bugs mailing list
```

12 Aug 2011 14:45

### Re: filename:join breaks Windows UNC paths

```
> -----Original Message-----
> Sorry to resurrect an old post, but this just bit me and cost
> me a day or
> two. Evgeny's patch works and applies to R14B01 and R14B03,
> though the line
> numbers are now a bit off. I've edited the patch below.
>
> Not sure what the proper convention is, but I'd like to vote
> for this being included in a future release if possible.
> a drive letter is no longer valid, especially if
> extended-path name notation is being used
> (\\?\very\long\path). This is an increasingly common need.

I'd like to add a vote for having this problem fixed since we
have also been bit by this.

It also appears that some "pathfunctions" like file:get_cwd/0
already support the "dubble-slash" syntax. The following shell
interaction shows the problem we've had:

1> {ok, Path} = file:get_cwd().
{ok, "//host/share"}
2> filename:join(Path, "file.txt").
"/host/share/file.txt"

Notice that the dubble-slash returned by file:get_cwd/0 gets lost
in the call to filename:join/2.

```

12 Aug 2011 23:50

### Repeatable output from crypto:rand_uniform with negative Low value

```Hi,

I've noticed that repeated calls to crypto:rand_uniform return the
same values if Low is negative and High is (approximately) equal to
-Low, and the answer is also outside of the requested range.

e.g,;

7> crypto:rand_uniform(-10000,10000).
65536
8> crypto:rand_uniform(-10000,10000).
65536
9> crypto:rand_uniform(-10000,10000).
65536

This is with R14B03.

Regards,
B.
_______________________________________________
erlang-bugs mailing list
erlang-bugs <at> erlang.org
http://erlang.org/mailman/listinfo/erlang-bugs

```
14 Aug 2011 05:02

### Re: filename:join breaks Windows UNC paths

```On 20 July 2011 05:27, wohali <joant <at> ieee.org> wrote:
> Sorry to resurrect an old post, but this just bit me and cost me a day or
> two. Evgeny's patch works and applies to R14B01 and R14B03, though the line
> numbers are now a bit off. I've edited the patch below.
>
> Not sure what the proper convention is, but I'd like to vote for this being
> included in a future release if possible. The current assumption that all
> paths on win32 start with a drive letter is no longer valid, especially if
> extended-path name notation is being used (\\?\very\long\path). This is an
> increasingly common need.
>
> ------------------- patch --------------------------------
> diff --git a/lib/stdlib/src/filename.erl b/lib/stdlib/src/filename.erl
> index 01c06e4..8da54ef 100644
> --- a/lib/stdlib/src/filename.erl
> +++ b/lib/stdlib/src/filename.erl
>  <at>  <at>  -426,6 +426,10  <at>  <at>  join(Name1, Name2) when is_atom(Name2) ->
>  %% It is the responsibility of the caller to ensure that RelativeName
>  %% is relative.
>
> +join1([\$/, \$/ | Rest], RelativeName, [], win32) -> [\$/, \$/ | join1(Rest,
> RelativeName, [], win32)];
> +join1([\$/, \$\\ | Rest], RelativeName, [], win32) -> [\$/, \$/ | join1(Rest,
> RelativeName, [], win32)];
> +join1([\$\\, \$/ | Rest], RelativeName, [], win32) -> [\$/, \$/ | join1(Rest,
> RelativeName, [], win32)];
> +join1([\$\\, \$\\ | Rest], RelativeName, [], win32) -> [\$/, \$/ | join1(Rest,
> RelativeName, [], win32)];
>  join1([UcLetter, \$:|Rest], RelativeName, [], win32)
>  when is_integer(UcLetter), UcLetter >= \$A, UcLetter =< \$Z ->
```

15 Aug 2011 00:18

### SIGBUS on init:restart()

```If I compile OTP R14B03 (also tried R14B01, and got same issue) for
64bits mode in Mac OS X Lion, when calling init:restart() in my
application I get a SIGBUS signal, which causes the VM to terminate
(it happens very often, but not always) with the error message "Bus
error: 10".

Here's some information from gdb which might be useful:

http://friendpaste.com/AL9GKX2pNdyb3NIEYWxcR

Ignoring the SIGBUS signal prevents the crash, but this is likely

diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c
index bafbbb0..86c3f57 100644
--- a/erts/emulator/sys/unix/sys.c
+++ b/erts/emulator/sys/unix/sys.c
<at>  <at>  -3031,6 +3031,9  <at>  <at>  erts_sys_main_thread(void)
int res;

+    signal(SIGPIPE, SIG_IGN);
+    signal(SIGBUS, SIG_IGN);
+
NULL, NULL, NULL);

OTP was configured like this:
```

15 Aug 2011 02:58

### Re: SIGBUS on init:restart()

```Found out the issue. It turned out to be a bad cast in linked in
driver from CouchDB:

diff --git a/src/couchdb/priv/icu_driver/couch_icu_driver.c
b/src/couchdb/priv/icu_driver/couch_icu_driver.c
index 9f20e99..edfd84a 100644
--- a/src/couchdb/priv/icu_driver/couch_icu_driver.c
+++ b/src/couchdb/priv/icu_driver/couch_icu_driver.c
<at>  <at>  -45,7 +45,7  <at>  <at>  static void couch_drv_stop(ErlDrvData data)
if (pData->collNoCase) {
ucol_close(pData->collNoCase);
}
-    driver_free((char*)pData);
+    driver_free((void*)pData);
}

static ErlDrvData couch_drv_start(ErlDrvPort port, char *buff)

On Sun, Aug 14, 2011 at 3:18 PM, Filipe David Manana
<fdmanana <at> apache.org> wrote:
> If I compile OTP R14B03 (also tried R14B01, and got same issue) for
> 64bits mode in Mac OS X Lion, when calling init:restart() in my
> application I get a SIGBUS signal, which causes the VM to terminate
> (it happens very often, but not always) with the error message "Bus
> error: 10".
>
> Here's some information from gdb which might be useful:
>
> http://friendpaste.com/AL9GKX2pNdyb3NIEYWxcR
>
```

15 Aug 2011 03:45

### Re: SIGBUS on init:restart()

A typecast? That shouldn't affect code generation like that. Are you sure you didn't just need to do a clean build or something?

On Sun, Aug 14, 2011 at 7:58 PM, Filipe David Manana wrote:
Found out the issue. It turned out to be a bad cast in linked in
driver from CouchDB:

diff --git a/src/couchdb/priv/icu_driver/couch_icu_driver.c
b/src/couchdb/priv/icu_driver/couch_icu_driver.c
index 9f20e99..edfd84a 100644
--- a/src/couchdb/priv/icu_driver/couch_icu_driver.c
+++ b/src/couchdb/priv/icu_driver/couch_icu_driver.c
<at> <at> -45,7 +45,7 <at> <at> static void couch_drv_stop(ErlDrvData data)
if (pData->collNoCase) {
ucol_close(pData->collNoCase);
}
-    driver_free((char*)pData);
+    driver_free((void*)pData);
}

static ErlDrvData couch_drv_start(ErlDrvPort port, char *buff)

On Sun, Aug 14, 2011 at 3:18 PM, Filipe David Manana
<fdmanana <at> apache.org> wrote:
> If I compile OTP R14B03 (also tried R14B01, and got same issue) for
> 64bits mode in Mac OS X Lion, when calling init:restart() in my
> application I get a SIGBUS signal, which causes the VM to terminate
> (it happens very often, but not always) with the error message "Bus
> error: 10".
>
> Here's some information from gdb which might be useful:
>
> http://friendpaste.com/AL9GKX2pNdyb3NIEYWxcR
>
> Ignoring the SIGBUS signal prevents the crash, but this is likely
>
> diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c
> index bafbbb0..86c3f57 100644
> --- a/erts/emulator/sys/unix/sys.c
> +++ b/erts/emulator/sys/unix/sys.c
> <at> <at> -3031,6 +3031,9 <at> <at> erts_sys_main_thread(void)
>        int res;
>
> +    signal(SIGPIPE, SIG_IGN);
> +    signal(SIGBUS, SIG_IGN);
> +
> NULL, NULL, NULL);
>
>
> OTP was configured like this:
>
> \$ CFLAGS="-O0" ./configure --enable-darwin-64bit --prefix=/opt/r14b03
>
> Without the --enable-darwin-64bit option, the issue doesn't happen.
>
> Is this a known issue or can it be application-specific? How to debug
> it further?
>
> This issue doesn't seem to happen on Linux and Mac OS X snowleopard systems.
>
> thanks
>
>
> --
> Filipe David Manana,
> fdmanana <at> gmail.com, fdmanana <at> apache.org
>
> "Reasonable men adapt themselves to the world.
>  Unreasonable men adapt the world to themselves.
>  That's why all progress depends on unreasonable men."
>

--
Filipe David Manana,
fdmanana <at> gmail.com, fdmanana <at> apache.org

"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."
_______________________________________________
erlang-bugs mailing list
erlang-bugs <at> erlang.org
http://erlang.org/mailman/listinfo/erlang-bugs

```_______________________________________________
erlang-bugs mailing list
erlang-bugs <at> erlang.org
http://erlang.org/mailman/listinfo/erlang-bugs
```

Gmane