<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
{font-family:"\@MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Here's the first real clue. The example driver is being unloaded before it's invoked! See below for the call stack of the unload.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>This must be either a bug in the documentation at <o:p></o:p></span></p><p class=MsoNormal><a href="http://www.erlang.org/doc/tutorial/c_portdriver.html" target="_blank">http://www.erlang.org/doc/tutorial/c_portdriver.html</a><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>or a bug in the erlang itself.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>What's the process for filing a bug?<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>0439f644 517572e2 example_drv!example_drv_finish(void)+0x1e [c:\users\jeff\code\code\port_driver\port_driver.cpp @ 64]<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>0439f654 51757729 beam_smp!do_unload_driver_entry(struct DE_Handle * dh = 0x00000000, unsigned long * save_name = 0x00000000)+0x72 [c:\users\jeff\github\otp\erts\emulator\beam\erl_bif_ddll.c @ 1655]<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>0439f680 51797c2b beam_smp!ddll_no_more_references(void * vdh = 0x517576d0)+0x59 [c:\users\jeff\github\otp\erts\emulator\beam\erl_bif_ddll.c @ 1221]<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>0439f69c 5179b89f beam_smp!exec_misc_ops(struct ErtsRunQueue_ * rq = 0x518c3b8c)+0x7b [c:\users\jeff\github\otp\erts\emulator\beam\erl_process.c @ 7231]<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>0439f6c8 51801be7 beam_smp!schedule(struct process * p = 0x00000002, int calls = 0)+0x5df [c:\users\jeff\github\otp\erts\emulator\beam\erl_process.c @ 6891]<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>0439f6fc 7714c7c5 beam_smp!process_main+0x167<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Robert Raschke [mailto:rtrlists@googlemail.com] <br><b>Sent:</b> Thursday, January 03, 2013 12:37 AM<br><b>To:</b> SurferJeff<br><b>Cc:</b> erlang-questions@erlang.org; erlang-programming@googlegroups.com<br><b>Subject:</b> Re: [erlang-questions] open_port returns enoent even when driver init function executes correctly.<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p>You can try running erl.exe with sasl enabled to get better error messages.<o:p></o:p></p><p>The messages you see at the moment are coming out interleaved, like in the old joke "When faced with a problem you decide to use threading, ..." :-)<o:p></o:p></p><p>Robby<o:p></o:p></p><div><p class=MsoNormal>On Jan 3, 2013 4:53 AM, "SurferJeff" <<a href="mailto:surferjeff@gmail.com">surferjeff@gmail.com</a>> wrote:<o:p></o:p></p><div><p class=MsoNormal>I found the recipe to build debug:<o:p></o:p></p></div><div><pre>$ cd $ERL_TOP<o:p></o:p></pre><pre>$ rm bin/win32/erlexec.dll<o:p></o:p></pre><pre>$ cd erts/emulator<o:p></o:p></pre><pre>$ make debug<o:p></o:p></pre><pre>$ cd ../etc<o:p></o:p></pre><pre>$ make debug<o:p></o:p></pre></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>And it succeeded. However, the next command in the recipe fails:<o:p></o:p></p></div><div><p class=MsoNormal><a href="mailto:jeff@lenovo" target="_blank"><span style='font-family:"Courier New"'>jeff@lenovo</span></a><span style='font-family:"Courier New"'> /cygdrive/c/Users/jeff/GitHub/otp<br>$ make local_setup<br>make[1]: Entering directory `/cygdrive/c/Users/jeff/GitHub/otp/erts'<br>make[2]: Entering directory `/cygdrive/c/Users/jeff/GitHub/otp/erts/start_script<br>s'<br>make[2]: Nothing to be done for `debug'.<br>make[2]: Leaving directory `/cygdrive/c/Users/jeff/GitHub/otp/erts/start_scripts<br>'<br>ct_run.exe dialyzer.exe erl.ini erl_crash.dump escript.exe run_test.exe typer.ex<br>e werl.exe win32<br>make[2]: Entering directory `/cygdrive/c/Users/jeff/GitHub/otp/erts/start_script<br>s'<br>/usr/bin/install -c -d /cygdrive/c/users/jeff/github/otp/erts/start_scripts/tmp<br>( cd /cygdrive/c/users/jeff/github/otp/erts/start_scripts/tmp && \<br> erlc -W -I/cygdrive/c/users/jeff/github/otp/lib/kernel/ebin -I/cygdrive/c/use<br>rs/jeff/github/otp/lib/stdlib/ebin -I/cygdrive/c/users/jeff/github/otp/lib/sasl/<br>ebin +no_warn_sasl +otp_build -o /cygdrive/c/users/jeff/github/otp/bin/start.scr<br>ipt /cygdrive/c/users/jeff/github/otp/erts/start_scripts/start_clean.rel )<br>File not found: "c:/cygdrive/c/users/jeff/github/otp/erts/start_scripts/start_cl<br>ean.rel"<br>Makefile:129: recipe for target `/cygdrive/c/users/jeff/github/otp/bin/start.scr<br>ipt' failed<br>make[2]: *** [/cygdrive/c/users/jeff/github/otp/bin/start.script] Error 1<br>make[2]: Leaving directory `/cygdrive/c/Users/jeff/GitHub/otp/erts/start_scripts<br>'<br>Makefile:69: recipe for target `local_setup' failed<br>make[1]: *** [local_setup] Error 2<br>make[1]: Leaving directory `/cygdrive/c/Users/jeff/GitHub/otp/erts'<br>Makefile:883: recipe for target `local_setup' failed<br>make: *** [local_setup] Error 2</span><o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>And now my erl.exe is completely hosed:<o:p></o:p></p></div><div><p class=MsoNormal><a href="mailto:jeff@lenovo" target="_blank"><span style='font-family:"Courier New"'>jeff@lenovo</span></a><span style='font-family:"Courier New"'> /cygdrive/c/Users/jeff/GitHub/otp/bin/win32<br>$ ./erl.exe<br>{(no error logger present"i)n ietr rtoerr: m"iEnrartoirn gi ni np rdooc_ebsoost<br>"<,0{.b2a.d0a>r wgi,t[h{ eerxli_tp rviaml_uleo:a d{ebra,dcahregc,k[_{feirlle__pr<br>reismu_llto,a3d,e[r{,fcihleec,k"_efrill_ep_rriems_ullota,d3er,[.{efrill"e},,\{"l<br>eirnle_,p28r3i}m]_}l,o{aidneirt.,egrelt\_"b}o,o{tl,i1n,e[,{2f8i3l}e,]"}i,n{iitn.<br>ite,rgle"t},_{bloionte,,178,5[}{]f}i,l{ei,n\i"ti,ngiett._ebrolo\t",}2,,{[l{ifnie<br>l,e7,8"5i}n]i}t,.{eirnli"t},,g{elti_nbeo,o77t2,}2]},,[{{ifniilte,,d\o"_ibnoiott.<br>,e3r,l[\{"f}i,l{el,i"nien,i7t7.2e}r]l}",}{,i{nliitn,ed,o73_9b}o]o}t],}3},<br>[{file,\"init.erl\"},{line,739}]}]}\n"</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'>Crash dump was written to: erl_crash.dump<br>init terminating in do_boot ()</span><o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal><br>On Wednesday, January 2, 2013 7:26:09 PM UTC-8, SurferJeff wrote:<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><p class=MsoNormal>I'm working through the example here: <br><a href="http://www.erlang.org/doc/tutorial/c_portdriver.html" target="_blank">http://www.erlang.org/doc/tutorial/c_portdriver.html</a> <br>And I'm trying to get it to run on Windows. I reordered the code in the C <br>source so that it compiles, and added a module.def file so that erlang <br>actually finds and executes the driver init function. <br><br>I attached a debugger. Walking back up the stack, I observe that: <br>The driver init function returns correctly. <br>erts_sys_ddll_call_init() returns correctly. <br>do_load_driver_entry() returns ERL_DE_NO_ERROR. <br>load_driver_entry() returns ERL_DE_NO_ERROR. <br>erl_ddll_try_load_3 returns t = TUPLE2(hp, am_ok, ok_term); on line 417 of <br>erl_bif_ddl.c. <br>But the next higher call on the stack is _process_main(), which was compiled <br>with gcc and has no debug symbols so I can't step through and figure out why <br>the end result is: <br><br>=ERROR REPORT==== 2-Jan-2013::19:14:22 === <br>Error in process <0.31.0> with exit value: <br>{enoent,[{erlang,open_port,[{spawn,"example_drv"},[]],[]},{complex5,init,1,[ <br>{file,"c:/Users/jeff/code/code/port_driver/complex5.erl"},{line,19}]}]} <br><br>Has anyone seen this before? <br><br>If not, how do I recompile erl.exe purely with cl.exe (no gcc) so that it <br>generates debug symbols? And while I'm recompiling, how do I turn off all <br>optimizations? I can read basic make files, but I get lost in the configure <br>scripts and .in and .mk files. Please take pity on a Windows programmer ;-) <br><br><br>_______________________________________________ <br>erlang-questions mailing list <br><a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a> <br><a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a> <o:p></o:p></p></blockquote><p class=MsoNormal style='margin-bottom:12.0pt'><br>_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br><a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><o:p></o:p></p></div></div></div></body></html>