<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<div>
<div id="x_compose-container" itemscope="" itemtype="https://schema.org/EmailMessage" style="direction:ltr">
<span itemprop="creator" itemscope="" itemtype="https://schema.org/Organization"><span itemprop="name"></span></span>
<div>
<div style="direction:ltr">Complete wild guess, but is there a difference in nif initialization running off the main thread in non-working version? This would be a problem for some low-level Mach related things. Not near laptop to look through the code to see
if that changed.</div>
<div><br>
</div>
<div><br>
</div>
<div class="x_acompli_signature">Get <a href="https://aka.ms/o0ukef">Outlook for iOS</a></div>
</div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> erlang-questions-bounces@erlang.org <erlang-questions-bounces@erlang.org> on behalf of Igor Clark <igor.clark@gmail.com><br>
<b>Sent:</b> Monday, April 17, 2017 4:38:11 PM<br>
<b>To:</b> erlang-questions@erlang.org<br>
<b>Subject:</b> [erlang-questions] NIF+device problem moving R18->R19 / Mac 10.11->10.12</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Hi all,<br>
<br>
I'm having problems updating a NIF to work correctly with R19 and/or <br>
MacOS Sierra (10.12). The NIF uses Mac OS C API calls to talk to some <br>
hardware. It's been working just fine with R18 on El Capitan, but it <br>
fails in a manner I don't understand when I trying to run it on R19 or <br>
Sierra. I'm pretty baffled as to what's going on, and wonder if any of <br>
the following might ring bells or set off a spider-sense for anyone here?<br>
<br>
- The code continues to work 100% as expected on R18 / Mac OS El Capitan <br>
(10.11), as it has for the last year or so.<br>
<br>
- On R19 on El Capitan, 99% of the C code works as before, but one <br>
particular MacOS C API call fails unexpectedly. It doesn't crash or <br>
cause errors directly, but it returns null instead of a valid value as <br>
before. There are no build errors or warnings. (I'm using 'pc' plugin <br>
version 1.5.0 with rebar3). Other MacOS API calls talking to the same <br>
hardware work as expected, sending correct commands, getting the <br>
hardware to carry out operations as expected and returning expected <br>
values, without any problems.<br>
<br>
- On both R18 & R19 on Sierra, exactly the same problem occurs as above <br>
in R19 on El Capitan.<br>
<br>
- If I make the failing/null-returning OS API call in a plain, <br>
simple-as-possible C file compiled with gcc (Apple LLVM/clang), it works <br>
as expected, *on both OS versions*.<br>
<br>
- If I paste that same simple-as-possible C code verbatim into the NIF, <br>
as the first line in the load() function, and run it on R18/El Capitan, <br>
it continues to work as expected.<br>
<br>
- If I then try to run that identical pasted-verbatim NIF code with no <br>
changes on R18/Sierra or on R19 & either OS version, this one particular <br>
function call fails, as above.<br>
<br>
I realise it could be many things, and my initial thought was that it <br>
must be the OS change or even the hardware failing - but the hardware <br>
and C API call continue to work just fine on both OS versions when the <br>
NIF stuff is taken out of the picture, and on El Capitan, the <br>
previously-not-happening problem reliably (and only) starts happening <br>
when I switch from R18 to R19.<br>
<br>
Did anything change between R18 and R19 that might somehow make some, <br>
but not all, external C function calls fail on El Capitan/clang 8.0.0? <br>
And could that be something that also makes the same thing happen on <br>
both R18 and R19 under Sierra/clang 8.1.0? Could it perhaps be something <br>
do with the port compiler & LD/CXX flags?<br>
<br>
Any ideas as to where else I could look to try to track this down, or <br>
what might be causing this?<br>
<br>
(BTW, I'm using homebrew erlang, and I've tried all the above with <br>
versions 18.1, 18.3, 19.0.2 and 19.3 on both OS versions. The gcc/clang <br>
version on El Capitan is from Xcode 8.1, "Apple LLVM version 8.0.0 <br>
(clang-800.0.42.1)". On Sierra it's from Xcode 8.3.1, "Apple LLVM <br>
version 8.1.0 (clang-802.0.41)" - but as above, the plain/non-NIF C code <br>
works perfectly and identically on both versions.)<br>
<br>
Thanks very much,<br>
Igor<br>
_______________________________________________<br>
erlang-questions mailing list<br>
erlang-questions@erlang.org<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__erlang.org_mailman_listinfo_erlang-2Dquestions&d=DwICAg&c=L_h2OePR2UWWefmqrezxOsP9Uqw55rRfX5bRtw9S4KY&r=PevFox_7LK44ZV_jlS5jRM2WItKtsHV4zN_CrbdT2aM&m=VYIypVbNEBkrDndUBzmlPhRtnzb4ZWIKbuytw-ZNFsQ&s=jm04c9Iw58-WmaHYaGFw-a9XQ3sFl2wqkf7RhdBDC6E&e=">https://urldefense.proofpoint.com/v2/url?u=http-3A__erlang.org_mailman_listinfo_erlang-2Dquestions&d=DwICAg&c=L_h2OePR2UWWefmqrezxOsP9Uqw55rRfX5bRtw9S4KY&r=PevFox_7LK44ZV_jlS5jRM2WItKtsHV4zN_CrbdT2aM&m=VYIypVbNEBkrDndUBzmlPhRtnzb4ZWIKbuytw-ZNFsQ&s=jm04c9Iw58-WmaHYaGFw-a9XQ3sFl2wqkf7RhdBDC6E&e=</a>
<br>
</div>
</span></font>Confidentiality Notice | This email and any included attachments may be privileged, confidential and/or otherwise protected from disclosure. Access to this email by anyone other than the intended recipient is unauthorized. If you believe you have
received this email in error, please contact the sender immediately and delete all copies. If you are not the intended recipient, you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is
strictly prohibited.
</body>
</html>