Segmentation fault: sel_ldr (Pepper 18)

907 views
Skip to first unread message

Mike Acton

unread,
Apr 22, 2012, 2:05:27 AM4/22/12
to native-cli...@googlegroups.com
Can anyone offer insight into using sel_ldr on Pepper 18? I can't seem to run anything.

How I'm trying to run:
~/nacl_sdk/pepper_18/tools/sel_ldr_x86_64 -f hello_world_x86_64.nexe

I'm on (uname -a):
Linux ip-10-168-221-158 3.0.0-16-virtual #28-Ubuntu SMP Fri Jan 27 18:22:35 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

The output from sel_ldr_x86_64:
[11757,2614712160:05:53:22.284542] Native Client module will be loaded at base address 0x00007fc700000000
Segmentation fault

Verbose output (-v):
[11801,2437584736:06:02:41.906677] NaClPerfCounterInterval(SelMain __start__:SnapshotNaclFile): 2250 microsecs
[11801,2437584736:06:02:41.907013] NaClPerfCounterInterval(NaClAppLoadFile __start__:PreAllocAddrSpace): 37 microsecs
[11801,2437584736:06:02:41.907214] Native Client module will be loaded at base address 0x00007fe400000000
[11801,2437584736:06:02:41.907392] NaClPerfCounterInterval(NaClAppLoadFile PreAllocAddrSpace:*AllocAddrSpace): 377 microsecs
[11801,2437584736:06:02:41.912955] NaClPerfCounterInterval(NaClAppLoadFile *AllocAddrSpace:*MakeDynText): 5563 microsecs
[11801,2437584736:06:02:41.924381] NaClPerfCounterInterval(NaClAppLoadFile *MakeDynText:*ValidateImg): 11427 microsecs
[11801,2437584736:06:02:41.924939] NaClPerfCounterInterval(NaClAppLoadFile __start__:EndLoadFile): 17963 microsecs
[11801,2437584736:06:02:41.925112] NaClPerfCounterInterval(SelMain SnapshotNaclFile:AppLoadEnd): 18437 microsecs
printing NaClApp details
NaClAppPrintDetails((struct NaClApp *) 0x7ffff09a1670,(struct Gio *) 0x7ffff09a1640)
addr space size:  2**32
stack size:       0x01000000
mem start addr:   0x7fe400000000
static_text_end:   0x00050000
end-of-text:       0x00050000
rodata:            0x10020000
data:              0x10040000
data_end:          0x10041e48
break_addr:        0x10041e48
ELF initial entry point:  0x0002c040
ELF user entry point:  0x00000000
memory map:

Page   0 (0x0)
npages 16 (0x10)
start vaddr 0x0
end vaddr   0x10000
prot   0x00000000
not shared/backed by a file

Page   16 (0x10)
npages 64 (0x40)
start vaddr 0x10000
end vaddr   0x50000
prot   0x00000005
not shared/backed by a file

Page   80 (0x50)
npages 65488 (0xffd0)
start vaddr 0x50000
end vaddr   0x10020000
prot   0x00000005
shared/backed by a file

Page   65568 (0x10020)
npages 32 (0x20)
start vaddr 0x10020000
end vaddr   0x10040000
prot   0x00000001
not shared/backed by a file

Page   65600 (0x10040)
npages 16 (0x10)
start vaddr 0x10040000
end vaddr   0x10050000
prot   0x00000003
not shared/backed by a file

Page   1044480 (0xff000)
npages 4096 (0x1000)
start vaddr 0xff000000
end vaddr   0x100000000
prot   0x00000003
not shared/backed by a file
[11801,2437584736:06:02:41.931800] NaClPerfCounterInterval(SelMain AppLoadEnd:AppPrepLaunch): 6688 microsecs
[11801,2437584736:06:02:41.932009] NACL: Application output follows
[11801,2437584736:06:02:41.932391] NaClPerfCounterInterval(SelMain AppPrepLaunch:CreateMainThread): 589 microsecs
Segmentation fault
 
The nexe validates okay:
~/nacl_sdk/pepper_18/tools/ncval_x86_64 hello_world_x86_64.nexe
 
VALIDATOR: segment[0] p_type 6 p_offset 0 vaddr 0 paddr 0 align 8
VALIDATOR:     filesz 120 memsz 120 flags 4
VALIDATOR: segment[1] p_type 1 p_offset 10000 vaddr 20000 paddr 20000 align 65536
VALIDATOR:     filesz 206c0 memsz 206c0 flags 5
VALIDATOR: parsing segment 1
VALIDATOR: 200cc: Does not support LM feature, removing usage(s).
VALIDATOR: 2062c: Does not support CMOV feature, removing usage(s).
VALIDATOR: 230ef: Does not support SSE2 feature, removing usage(s).
VALIDATOR: 2c422: Does not support SSE feature, removing usage(s).
VALIDATOR: 2c7d0: Does not support MMX feature, removing usage(s).
VALIDATOR: 2c8fc: Does not support CLFLUSH feature, removing usage(s).
VALIDATOR: 2c8fc: Does not support SFENCE feature, removing usage(s).
VALIDATOR: Checking block alignment and jump targets: 20000 to 406c0
VALIDATOR: segment[2] p_type 1 p_offset 40000 vaddr 10020000 paddr 10020000 align 65536
VALIDATOR:     filesz 10474 memsz 10474 flags 4
VALIDATOR: segment[3] p_type 1 p_offset 60000 vaddr 10040000 paddr 10040000 align 65536
VALIDATOR:     filesz 6a8 memsz 1e48 flags 6
*** hello_world_x86_64.nexe is safe ***
*** hello_world_x86_64.nexe is safe ***

The source for hello_world.c does pretty much nothing:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "ppapi/c/pp_errors.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_var.h"
#include "ppapi/c/ppb.h"
#include "ppapi/c/ppb_instance.h"
#include "ppapi/c/ppb_messaging.h"
#include "ppapi/c/ppb_var.h"
#include "ppapi/c/ppp.h"
#include "ppapi/c/ppp_instance.h"
#include "ppapi/c/ppp_messaging.h"

static PP_Bool Instance_DidCreate(PP_Instance instance, uint32_t argc, const char* argn[], const char* argv[])
{
  return PP_TRUE;
}


static void Instance_DidDestroy(PP_Instance instance)
{
}

static void Instance_DidChangeView(PP_Instance instance, PP_Resource view_resource)
{
}

static void Instance_DidChangeFocus(PP_Instance instance, PP_Bool has_focus)
{
}

static PP_Bool Instance_HandleDocumentLoad(PP_Instance instance, PP_Resource url_loader)
{
  /* NaCl modules do not need to handle the document load function. */
  return PP_FALSE;
}

PP_EXPORT int32_t PPP_InitializeModule(PP_Module a_module_id, PPB_GetInterface get_browser)
{
  return PP_OK;
}


PP_EXPORT const void* PPP_GetInterface(const char* interface_name)
{
  if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) {
    static PPP_Instance instance_interface = {
      &Instance_DidCreate,
      &Instance_DidDestroy,
      &Instance_DidChangeView,
      &Instance_DidChangeFocus,
      &Instance_HandleDocumentLoad,
    };
    return &instance_interface;
  }
  return NULL;
}


/**
 * Called before the plugin module is unloaded.
 */
PP_EXPORT void PPP_ShutdownModule() {
}

Bennet Yee (余仕斌)

unread,
Apr 22, 2012, 3:32:58 AM4/22/12
to native-cli...@googlegroups.com

The pepper interfaces are implemented by proxying calls to the browser. Standalone sell_ldr won't be useful for that.  You'll have to create an nmf file and load the nexe via chrome.

As for the seg fault, it's probably because the IRT isn't being loaded. No need to worry about it -- when you test via the browser, that's taken care of.

-bsy

plz xqz tpos, rplyng by fone

--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/native-client-discuss/-/YGs2aj7GY1EJ.
To post to this group, send email to native-cli...@googlegroups.com.
To unsubscribe from this group, send email to native-client-di...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/native-client-discuss?hl=en.

Mike Acton

unread,
Apr 22, 2012, 5:16:12 AM4/22/12
to native-cli...@googlegroups.com
The pepper interfaces are implemented by proxying calls to the browser. Standalone sell_ldr won't be useful for that.  

Actually, I wasn't interested in the pepper interfaces. I'll try without them.

I have some file conversion functions (stdin->stdout) that I'd like to distribute with nacl projects (for offline, development use) and rather than worry about what another dev might have installed or what OS they're on, I thought it'd be handier to just build those with nacl so I can be confident anyone can run.

So... a new hello.c:
#include <stdio.h>

int
main( void )
{
  printf("hello, world.");
  return (0);
}

This one also segfaults:
~/nacl_sdk/pepper_18/tools/sel_ldr_x86_64 -f hello_world_x86_64.nexe
[17871,1502443360:09:13:49.017232] Native Client module will be loaded at base address 0x00007fd700000000

As for the seg fault, it's probably because the IRT isn't being loaded. No need to worry about it -- when you test via the browser, that's taken care of.

So what do I need to do to "load the IRT"? (What is IRT?)

Mike Acton

unread,
Apr 22, 2012, 6:14:37 AM4/22/12
to native-cli...@googlegroups.com
Whoops, forgot to copy that last line. But I bet you can guess what it was. ;)

This one also segfaults:
~/nacl_sdk/pepper_18/tools/sel_ldr_x86_64 -f hello_world_x86_64.nexe
[18912,2253166432:10:13:23.718015] Native Client module will be loaded at base address 0x00007f3800000000
Segmentation fault

Bennet Yee (余仕斌)

unread,
Apr 22, 2012, 11:07:34 AM4/22/12
to native-cli...@googlegroups.com

Add a -B flag with arg the path to the integrated runtime IRT which is untrusted code injected into the addr space that provides the stable ABI that libc etc uses. The path is, if you are building sell_ldr from the sources,  something like scons-out/.. /something-irt/.../*irt.nexe.  Not sure where it is in the SDK.

plz xqz tpos, rplyng by fone

--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.

Mike Acton

unread,
Apr 22, 2012, 4:32:12 PM4/22/12
to native-cli...@googlegroups.com
These are the only files with "irt" in the name:

./pepper_18/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/gil/virtual_locator.hpp
./pepper_18/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/python/pure_virtual.hpp
./pepper_18/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/type_traits/has_virtual_destructor.hpp
./pepper_18/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/type_traits/is_virtual_base_of.hpp
./pepper_18/toolchain/linux_x86_newlib/i686-nacl/usr/include/nacl-mounts/base/irt_syscalls.h
./pepper_18/toolchain/linux_x86_newlib/i686-nacl/usr/share/doc/ImageMagick-6.5.4/images/t-shirt.png
./pepper_18/toolchain/linux_x86_newlib/i686-nacl/usr/share/doc/ImageMagick-6.5.4/www/t-shirt.html
./pepper_18/toolchain/linux_x86_newlib/x86_64-nacl/include/irt_ppapi.h
./pepper_18/toolchain/linux_x86_newlib/x86_64-nacl/include/irt.h
./pepper_18/toolchain/linux_x86_glibc/x86_64-nacl/include/irt_ppapi.h
./pepper_18/toolchain/linux_x86_glibc/x86_64-nacl/include/irt.h

And there are no nexes outside of the examples.

Since sel_ldr is distributed with the SDK, my presumption is that it's intended that we can use it. True?

Mike.

Bennet Yee (余仕斌)

unread,
Apr 23, 2012, 1:22:52 AM4/23/12
to native-cli...@googlegroups.com
it might not be distributed with the SDK, since it's intended use is to develop chrome NaCl modules that use the Pepper interface, and your use case is different.  linux chrome includes it as

/opt/google/chrome/nacl_irt_x86_64.nexe

and the NaCl build produces it as (for example):

.../scons-out/nacl_irt-x86-64/staging/irt.nexe

the path will depend on the architecture since it's encoded in the pathname.  anyway, to get it you'll probably have to grab the T-o-T source from the NaCl repo and build it.  as for the reason that sel_ldr is included with the SDK, i think it may well have been to make it easier to test code, but i don't recall.

-bsy
--
bennet s yee
i usually don't capitalize due to mild tendonitis

Andrey Khalyavin

unread,
Apr 23, 2012, 4:38:20 AM4/23/12
to native-cli...@googlegroups.com
It is located in pepper_19/tools. You can execute
./naclsdk update pepper_19 (linux)
or
naclsdk.bat update pepper_19 (windows)
to download it.

Andrey Khalyavin


On Monday, April 23, 2012 12:32:12 AM UTC+4, Mike Acton wrote:
These are the only files with "irt" in the name:

./pepper_18/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/gil/virtual_locator.hpp
./pepper_18/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/python/pure_virtual.hpp
./pepper_18/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/type_traits/has_virtual_destructor.hpp
./pepper_18/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/type_traits/is_virtual_base_of.hpp
./pepper_18/toolchain/linux_x86_newlib/i686-nacl/usr/include/nacl-mounts/base/irt_syscalls.h
./pepper_18/toolchain/linux_x86_newlib/i686-nacl/usr/share/doc/ImageMagick-6.5.4/images/t-shirt.png
./pepper_18/toolchain/linux_x86_newlib/i686-nacl/usr/share/doc/ImageMagick-6.5.4/www/t-shirt.html
./pepper_18/toolchain/linux_x86_newlib/x86_64-nacl/include/irt_ppapi.h
./pepper_18/toolchain/linux_x86_newlib/x86_64-nacl/include/irt.h
./pepper_18/toolchain/linux_x86_glibc/x86_64-nacl/include/irt_ppapi.h
./pepper_18/toolchain/linux_x86_glibc/x86_64-nacl/include/irt.h

And there are no nexes outside of the examples.

Since sel_ldr is distributed with the SDK, my presumption is that it's intended that we can use it. True?

Mike.

On Sun, Apr 22, 2012 at 8:07 AM, Bennet Yee (余仕斌) wrote:

Add a -B flag with arg the path to the integrated runtime IRT which is untrusted code injected into the addr space that provides the stable ABI that libc etc uses. The path is, if you are building sell_ldr from the sources,  something like scons-out/.. /something-irt/.../*irt.nexe.  Not sure where it is in the SDK.

plz xqz tpos, rplyng by fone

On Apr 22, 2012 2:16 AM, "Mike Acton" wrote:
The pepper interfaces are implemented by proxying calls to the browser. Standalone sell_ldr won't be useful for that.  

Actually, I wasn't interested in the pepper interfaces. I'll try without them.

I have some file conversion functions (stdin->stdout) that I'd like to distribute with nacl projects (for offline, development use) and rather than worry about what another dev might have installed or what OS they're on, I thought it'd be handier to just build those with nacl so I can be confident anyone can run.

So... a new hello.c:
#include <stdio.h>

int
main( void )
{
  printf("hello, world.");
  return (0);
}

This one also segfaults:
~/nacl_sdk/pepper_18/tools/sel_ldr_x86_64 -f hello_world_x86_64.nexe
[17871,1502443360:09:13:49.017232] Native Client module will be loaded at base address 0x00007fd700000000

As for the seg fault, it's probably because the IRT isn't being loaded. No need to worry about it -- when you test via the browser, that's taken care of.

So what do I need to do to "load the IRT"? (What is IRT?)

--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/native-client-discuss/-/dFSNGfjxjuUJ.
To post to this group, send email to native-client-discuss@googlegroups.com.
To unsubscribe from this group, send email to native-client-discuss+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/native-client-discuss?hl=en.

--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.
To post to this group, send email to native-client-discuss@googlegroups.com.
To unsubscribe from this group, send email to native-client-discuss+unsub...@googlegroups.com.

Mike Acton

unread,
Apr 23, 2012, 4:44:42 AM4/23/12
to native-cli...@googlegroups.com
Thanks Andrey. Will give that a go.

To view this discussion on the web visit https://groups.google.com/d/msg/native-client-discuss/-/suwigpwYF7sJ.

To post to this group, send email to native-cli...@googlegroups.com.
To unsubscribe from this group, send email to native-client-di...@googlegroups.com.

AlainC

unread,
Apr 23, 2012, 10:53:27 AM4/23/12
to native-cli...@googlegroups.com

Le dimanche 22 avril 2012 17:07:34 UTC+2, Bennet Yee a écrit :

Add a -B flag with arg the path to the integrated runtime IRT which is untrusted code injected into the addr space that provides the stable ABI that libc etc uses. The path is, if you are building sell_ldr from the sources,  something like scons-out/.. /something-irt/.../*irt.nexe.  Not sure where it is in the SDK.

plz xqz tpos, rplyng by fone



These files figured in Pepper_16 and Pepper_17 SDK distros (in ...toolchain\win_x86\runtime or \toolchain\win_x86_newlib\runtime for instance),
disappeared in Pepper_18 and now are back in Pepper_19 SDK (in ...\tools).

Does it means that it was a mistake in Pepper_18 ?

It would be nice to
  • document a little bit the sel_ldr -B option (it seem mandatory to use it since Pepper_15)
  • also document this kind of changes between Pepper versions


Mike Acton

unread,
Apr 25, 2012, 4:11:36 AM4/25/12
to native-cli...@googlegroups.com
Bennet Yee: Add a -B flag with arg the path to the integrated runtime IRT which is untrusted code injected into the addr space that provides the stable ABI that libc etc uses. 
Andrey Khalyavin: It is located in pepper_19/tools. 

Success! Thanks, guys. :) Now I think I can assume that anyone developing for NaCl can run nexes, uh..., natively. So I don't need to worry about platforms to distribute simple conversion tools, scripts, etc.

$ ~/nacl_sdk/pepper_19/tools/sel_ldr_x86_64 -B ~/nacl_sdk/pepper_19/tools/irt_x86_64.nexe hello_x86_64.nexe < hello.c

[4388,794000928:08:04:38.924924] Native Client module will be loaded at base address 0x00002b4300000000
Hello, world! Echo input file (stdin)
Size of input file: 811
----- INPUT BEGIN -----
#include <stdio.h>
#include <alloca.h>

int
main( int argc, char** argv )
{
  printf("Hello, world! Echo input file (stdin)\n");

  size_t input_max_size = 4 * 1024 * 1024;
  char*  input_buffer   = alloca( input_max_size );

  if (!input_buffer)
  {
    printf("ERROR: Could not allocate buffer from stack.");
    return (-1);
  }
 
  int    c;
  size_t input_size   = 0;

  while (EOF != (c = fgetc(stdin))) {
    input_buffer[ input_size ] = (char)(uint8_t)c;
    input_size++;
    if ( input_size == input_max_size)
    {
      printf("Warning: File larger than maximum space allocated.\n");
      break;
    }
  }

  printf("Size of input file: %d\n",input_size);
  printf("----- INPUT BEGIN -----\n");
  fwrite( input_buffer, input_size, 1, stdout );
  printf("----- INPUT END -----\n");

  return (0);
}
----- INPUT END -----

Reply all
Reply to author
Forward
0 new messages