Segmentation fault in ARM/Linux(Android)

  1. 3 months ago

    I am trying to use your library in ARM/Linux(Android). I compiled it with a cross compiler (arm-linux-gnueabi-gcc and my host is Ubuntu)- everything compile well but if I try to execute a simple test where I have functions related to your library I get a segmentation fault. Do I have to do something special to compile for ARM/Linux with your library?

  2. admin

    Feb 21 Administrator

    Hej, aperez.

    The library has never been compiled and tested on Android, because that platform is not (yet) available.

    However, the library is actually almost competely independent of the platform. The only interaction between the library and the platform is the abstraction layer, which abstracts atomic instruction functionality and the like. It could be possible if this is incorrect for the library to crash.

    1. can you provide me with a stack track for the crash?
    2. can you provide me with a login to your system, so I can debug the problem?
    3. does the test programme compile and run successfully?
    4. the test you run - can you describe it? which lfds functions are in use?

    Another way forward here is for me to duplicate your build environment. What platform are you using to execute the Android binary?

    You can email as well, if you wish, "admin at liblfds dot org".

  3. Thanks for your replay.
    The C code that I am trying to execute is the next (basically the example that you provide in the documentation):

    #include <stdio.h>
    #include <string.h>
    #include "liblfds710.h"
    struct test_data
    int main()
      struct lfds710_queue_bmm_element
      struct lfds710_queue_bmm_state
      struct test_data
      lfds710_queue_bmm_init_valid_on_current_logical_core( &qbmms, &qbmme, 1, NULL );
      strcpy(, "Madge The Skutter" );
      lfds710_queue_bmm_enqueue( &qbmms, NULL, &td );
      lfds710_queue_bmm_dequeue( &qbmms, NULL, &temp_td );
      printf( "skutter name = %s\n", temp_td->name );
      lfds710_queue_bmm_cleanup( &qbmms, NULL );
      return 1;

    The previous code compile well without warnings and errors, but I get a segmentation fault when I execute it in Android 6.0. The fault occurs in the next line:

     lfds710_queue_bmm_init_valid_on_current_logical_core( &qbmms, &qbmme, 1, NULL );

    I have compiled your library and the test with this cross-compiler "arm-linux-gnueabi-gcc" in two ways:

    1. static: doesn't work (segmentation fault).
    2. no static using a dynamic-linker for ARM/Linux and a glibc standard: doesn't work (segmentation fault).
  4. admin

    Feb 21 Administrator
    Edited 3 months ago by admin

    I'm very sorry, aperez; this is an embarrassing documentation fault on my part.

    The number of elements given to the bounded/many/many queue must be a positive integer power of 2, i.e. 2, 4, 8, 16, etc. (In fact, the demo code is wrong - and that's a *really* bad mistake; it happened because there was so much documentation to write. Of course, any code not run is broken, and this is no exception. The library code itself is run extensively, by the test programme; the library is *not* treated as the example code was in this case.)

    There is an assert for this, and that is probably what is causing the crash. The init function itself is utterly simple - it just writes initial values into the state structure.

    I have read over the docs for the queue and I can find NOWHERE where this requirement is stated. This surprises me very deeply - but there it is.

    I don't have time to fix it this very instant - I have to leave in a minute - but I will correct it (describing the requirement, and fixing the sample code) tonight.

    In fact, what needs to happen is all the sample code is made part of the test suite, so it is always being run.

    Something I recently realised is that you can only offer work you can automate. Anything non-automated is simply too much work to keep doing manually.

  5. Thank you very much. You are right, with a positive even number everything works well in Android 6.0 with a Nexus 5.

  6. admin

    Feb 21 Administrator

    I'm glad, but I'm still mortified. Sample code which doesn't work is a cardinal sin. Thankyou for posting about it, so it became known.


or Sign Up to reply!