Search code examples
google-nativeclient

Error when running Native Client SDK examples


I had followed the instructions in https://developers.google.com/native-client/devguide/tutorial#verify

However, it seems all the examples are not running well. Had tried set NACL_SDK_ROOT to /nacl_sdk/ and /nacl_sdk/pepper_23/ but still no working

e.g., in "Interactive Hello World in C++", when trying to click the button of "Call reverseText()", nothing is seen. With development tools I see the console output is:

 Uncaught TypeError: Cannot call method 'postMessage' of null           example.js:25

Here is part of the example.js:

22: function reverseText() {
23:   // Grab the text from the text box, pass it into reverseText()
24:   var inputBox = document.getElementById('inputBox');
25:   common.naclModule.postMessage('reverseText:' + inputBox.value);
26: }

Looks like the reason is "common.naclMode is null". How to fix this error?

--EDIT--

When I was trying another example of "hello world", the output of http server is:

localhost - - [07/Jan/2013 15:52:42] "GET / HTTP/1.1" 200 -
localhost - - [07/Jan/2013 15:52:45] "GET /hello_world/index.html HTTP/1.1" 200 -
localhost - - [07/Jan/2013 15:52:45] "GET /hello_world/index_newlib_Debug.html HTTP/1.1" 200 -
localhost - - [07/Jan/2013 15:52:45] "GET /hello_world/common.js HTTP/1.1" 200 -
localhost - - [07/Jan/2013 15:52:45] "GET /hello_world/newlib/Debug/hello_world.nmf HTTP/1.1" 200 -
localhost - - [07/Jan/2013 15:52:45] "GET /hello_world/newlib/Debug/hello_world_x86_64.nexe HTTP/1.1" 200 -

I see following on the page:

Hello World.
Status: Creating embed: newlib

And the console outputs:

NativeClient: NaCl module load failed: Nexe crashed during startup

Here is ouput of objdump:

nacl_sdk/pepper_23/examples/hello_world$ ../.././toolchain/linux_x86_newlib/bin/x86_64-nacl-objdump -p newlib/Debug/hello_world_x86_64.nexe

newlib/Debug/hello_world_x86_64.nexe:     file format elf64-nacl

Program Header:
    PHDR off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**3
         filesz 0x0000000000000120 memsz 0x0000000000000120 flags r--
    LOAD off    0x0000000000010000 vaddr 0x0000000000020000 paddr 0x0000000000020000 align 2**16
         filesz 0x0000000000021ac0 memsz 0x0000000000021ac0 flags r-x
    LOAD off    0x0000000000040000 vaddr 0x0000000010020000 paddr 0x0000000010020000 align 2**16
         filesz 0x0000000000010474 memsz 0x0000000000010474 flags r--
    LOAD off    0x0000000000060000 vaddr 0x0000000010040000 paddr 0x0000000010040000 align 2**16
         filesz 0x00000000000006e8 memsz 0x0000000000001da8 flags rw-

Output of chrome with VERBOSITY=5:

[deqing@hdell]~/works/nacl_sdk/pepper_23$ export NACLVERBOSITY=5
[deqing@hdell]~/works/nacl_sdk/pepper_23$ google-chrome http://localhost:5103 
[7,3729430976:11:56:19.763373] NaClRefCountCtor(0x7fb3e5184ac0).
[7,3729430976:11:56:19.763465] NexeFileDidOpen: invoking LoadNaClModule
...
[12,1392863616:03:56:19.825517] nacl_debug(136) : Debugging started.
[12,1392863616:03:56:19.825545] setting stack to : 00007fcefffeffa0
[12,1392863616:03:56:19.825557] copying arg 0  0x7fd95a7b1a40 -> 0x7fcefffeffd0
[12,1392863616:03:56:19.825568] copying env 0  0x7ffff4941bd6 -> 0x7fcefffeffd9
[12,1392863616:03:56:19.825575] copying env 1  0x7ffff4941c95 -> 0x7fcefffeffea
[12,1392863616:03:56:19.825583] system stack ptr : 00007fcefffeff98
[12,1392863616:03:56:19.825589]   user stack ptr : 00007fcefffeff98
[12,1392863616:03:56:19.825595]          natp = 0x000000000181fa80
[12,1392863616:03:56:19.825603]           nap = 0x00007ffff493b9a0
[12,1392863616:03:56:19.825609] usr_stack_ptr = 0x00007fcefffeff98
[12,1392863616:03:56:19.825639] NaClWaitForMainThreadToExit: taking NaClApp lock
[12,1392863616:03:56:19.825648]  waiting for exit status
[12,1376372480:03:56:19.825665] NaClThreadLauncher: entered
[12,1376372480:03:56:19.825684]       natp = 0x000000000181fa80
[12,1376372480:03:56:19.825691]  prog_ctr  = 0x00007fce0fc00200
[12,1376372480:03:56:19.825698] stack_ptr  = 0x00007fcefffeff98
[12,1376372480:03:56:19.825708] ix 0: 0x00000000
[12,1376372480:03:56:19.825716] found first not-all-ones ix 0
[12,1376372480:03:56:19.825723] Set(0,0x181fa80) @ix 0: 0x00000000
[12,1376372480:03:56:19.825729] After @ix 0: 0x00000001, avail_ix 0

Why the nexe crashed? Can anyone shed some light? Thanks.


Solution

  • the log message

    nacl_debug(136) : Debugging started.

    indicates you have "Native Client GDB-based debugging" turned on in about:flags. when this happens, gdb is expected to connect to port 4014. are connecting gdb to the debug stub? could you check your about:flags and turn off gdb-based debugging if you didn't really want it?