From: bugzilla at busybox.net <bugzilla@busybox.net>
To: buildroot@busybox.net
Subject: [Buildroot] [Bug 11166] Erlang bad argument on valid uint64 when crosscompiled on 64-bit host
Date: Thu, 16 Aug 2018 18:51:09 +0000 [thread overview]
Message-ID: <bug-11166-163-0pXRLb4q3T@https.bugs.busybox.net/> (raw)
In-Reply-To: <bug-11166-163@https.bugs.busybox.net/>
https://bugs.busybox.net/show_bug.cgi?id=11166
--- Comment #3 from Frank Vasquez <frankv@helium.com> ---
I have a very simple repro for this bug now. This bitcask example is taken
straight from Joe Armstrong's Programming Erlang book. Here I am running the
example on a Buildroot image cross-compiled on a 32-bit Linux VM.
# erl -pa ebin
Erlang/OTP 20 [erts-9.0] [source] [smp:2:2] [ds:2:2:10] [async-threads:10]
[kernel-poll:false]
Eshell V9.0 (abort with ^G)
1> Handle = bitcask:open("some_db", [read_write]).
#Ref<0.4215703536.2955149313.140816>
2> N = 1.
1
3> bitcask:put(Handle, <<"some_key">>, term_to_binary(N)).
ok
And here I am running the same example on a Buildroot image cross-compiled on a
64-bit Linux VM.
# erl -pa ebin
Erlang/OTP 20 [erts-9.0] [source] [smp:2:2] [ds:2:2:10] [async-threads:10]
[kernel-poll:false]
Eshell V9.0 (abort with ^G)
1> Handle = bitcask:open("some_db", [read_write]).
#Ref<0.992227993.3221749761.137832>
2> N = 1.
1
3> bitcask:put(Handle, <<"some_key">>, term_to_binary(N)).
** exception error: bad argument
in function bitcask_nifs:keydir_get_int/3
called as
bitcask_nifs:keydir_get_int(#Ref<0.992227993.3221880833.137823>,
<<"some_key">>,
18446744073709551615)
in call from bitcask_nifs:keydir_get/3
(/home/frank/nextgate/rootfs/output/build/erlccbug-0.1.0/_build/default/lib/bitcask/src/bitcask_nifs.erl,
line 181)
in call from bitcask:do_put/5
(/home/frank/nextgate/rootfs/output/build/erlccbug-0.1.0/_build/default/lib/bitcask/src/bitcask.erl,
line 1760)
in call from bitcask:put/3
(/home/frank/nextgate/rootfs/output/build/erlccbug-0.1.0/_build/default/lib/bitcask/src/bitcask.erl,
line 298)
Line 181 of bitcask_nifs.erl is the call to keydir_get_int(Ref, Key, Epoch)
below.
keydir_get(Ref, Key, Epoch) ->
case keydir_get_int(Ref, Key, Epoch) of
E when is_record(E, bitcask_entry) ->
<<Offset:64/unsigned-native>> = E#bitcask_entry.offset,
E#bitcask_entry{offset = Offset};
_ ->
not_found
end.
The bad argument exception is coming from this NIF code.
ERL_NIF_TERM bitcask_nifs_keydir_get_int(ErlNifEnv* env, int argc, const
ERL_NIF_TERM argv[])
{
bitcask_keydir_handle* handle;
ErlNifBinary key;
uint64 epoch; //intentionally odd type to get around warnings
if (enif_get_resource(env, argv[0], bitcask_keydir_RESOURCE,
(void**)&handle) &&
enif_inspect_binary(env, argv[1], &key) &&
enif_get_uint64(env, argv[2], &epoch))
{
...
}
else
{
return enif_make_badarg(env);
}
}
My theory is that the enif_get_uint64(env, argv[2], &epoch) condition is
returning false which should rarely be the case if Erlang is cross-compiled
correctly. Maybe Uint64 is incorrectly defined as unsigned long or something
to that effect when cross-compiling on a 64-bit VM.
--
You are receiving this mail because:
You are on the CC list for the bug.
next prev parent reply other threads:[~2018-08-16 18:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-21 5:43 [Buildroot] [Bug 11166] New: Erlang bad argument on valid uint64 when crosscompiled on 64-bit host bugzilla at busybox.net
2018-07-21 5:45 ` [Buildroot] [Bug 11166] " bugzilla at busybox.net
2018-07-21 6:35 ` bugzilla at busybox.net
2018-08-03 22:35 ` bugzilla at busybox.net
2018-08-14 20:31 ` bugzilla at busybox.net
2018-08-16 18:51 ` bugzilla at busybox.net [this message]
2018-08-16 22:45 ` bugzilla at busybox.net
2018-08-17 21:34 ` bugzilla at busybox.net
2018-08-20 17:16 ` bugzilla at busybox.net
2018-10-20 7:36 ` bugzilla at busybox.net
2018-10-20 7:39 ` bugzilla at busybox.net
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-11166-163-0pXRLb4q3T@https.bugs.busybox.net/ \
--to=bugzilla@busybox.net \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.