【问题标题】:Error when running Native Client SDK examples运行 Native Client SDK 示例时出错
【发布时间】:2013-01-07 08:00:24
【问题描述】:

我已按照https://developers.google.com/native-client/devguide/tutorial#verify中的说明进行操作

但是,似乎所有示例都没有运行良好。已尝试将 NACL_SDK_ROOT 设置为 /nacl_sdk//nacl_sdk/pepper_23/ 但仍然无法正常工作

例如,在“Interactive Hello World in C++”中,当尝试单击“Call reverseText()”按钮时,什么也看不到。 使用开发工具,我看到控制台输出是:

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

这里是 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: }

看起来原因是“common.naclMode 为空”。如何解决此错误?

--编辑--

当我尝试另一个“hello world”示例时,http server 的输出是:

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 -

我在页面上看到以下内容:

Hello World.
Status: Creating embed: newlib

控制台输出:

NativeClient: NaCl module load failed: Nexe crashed during startup

这是 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-

VERBOSITY=5 的 chrome 输出:

[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

为什么 nexe 崩溃了?任何人都可以解释一下吗?谢谢。

【问题讨论】:

  • 您正在显示 glibc 可执行文件的 objdump,而 Chrome 说它是崩溃的 newlib 可执行文件。
  • 此外,httpd 服务于 nexe 的 x86-64 版本,而不是 x86-32 版本。从 gnome-terminal(或 OSX 等价物)启动 chrome 并查看它是否有任何诊断输出会更有用。还可以尝试将 NACLVERBOSITY 环境变量设置为 3 或 4 以获取一些日志记录输出。
  • 根据@BennetYee 和 Ha 的 cmets 更新了我的问题。

标签: google-nativeclient


【解决方案1】:

日志消息

nacl_debug(136) : 调试开始。

表示您在 about:flags 中打开了“基于本机客户端 GDB 的调试”。发生这种情况时,gdb 应该连接到端口 4014。正在将 gdb 连接到调试存根吗?如果你真的不想要的话,你能检查一下你的 about:flags 并关闭基于 gdb 的调试吗?

【讨论】:

  • 非常感谢!这真的很有帮助。当我尝试测试时,我只是打开了所有与 nacl 相关的选项,并没有详细研究它们。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多