Shared library minor version management

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












I have a simple program called main:



#include <iostream>
#include "random.h"

int main()

std::cout << "The program has startedn";
return get_another_random_number();



The get_another_random_number() function is in a new version of a shared library, but only the old version is installed. The program begins running, but crashes at a later time when the lookup fails; e.g.



$ ./main
The program has started
./main: symbol lookup error: ./main: undefined symbol: _Z25get_another_random_numberv



This will happen if, for example, librandom.so.1.3.1 contains a function called get_another_random_number(), but main is executed on a server that has only librandom.so.1.2.5 installed. These libraries differ only in their minor version because the 1.3 version is backwards compatible with the 1.2 version of the library, but 1.2 lacks the extra function.



In my own example if I run readelf -d main | grep NEEDED I get:



 0x0000000000000001 (NEEDED) Shared library: [librandom.so.1]
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]


So everything is linked against the major version numbers only.



For my shared library I placed it in /usr/lib/ and added the symlinks:



lrwxrwxrwx 1 root root 23 Feb 7 14:25 /usr/lib/librandom.so -> /usr/lib/librandom.so.1
lrwxrwxrwx 1 root root 27 Feb 7 14:13 /usr/lib/librandom.so.1 -> /usr/lib/librandom.so.1.2.5
-rw-r--r-- 1 root root 7696 Feb 7 14:00 /usr/lib/librandom.so.1.2.5


Between the library maintainer, application developer and system administrator; who takes responsibility for avoiding this program crash?



  • Is it during installation of main that an error should be produced stating that the currently installed library's minor version is too low?

  • Should the program call a special function in the library to identify the version and check if the minor version is enough?

  • Is the library loader supposed to check all the symbols before the program starts running?

  • Have I misunderstood the version numbering or missed a setting to check the minor version?






share|improve this question
























    up vote
    3
    down vote

    favorite












    I have a simple program called main:



    #include <iostream>
    #include "random.h"

    int main()

    std::cout << "The program has startedn";
    return get_another_random_number();



    The get_another_random_number() function is in a new version of a shared library, but only the old version is installed. The program begins running, but crashes at a later time when the lookup fails; e.g.



    $ ./main
    The program has started
    ./main: symbol lookup error: ./main: undefined symbol: _Z25get_another_random_numberv



    This will happen if, for example, librandom.so.1.3.1 contains a function called get_another_random_number(), but main is executed on a server that has only librandom.so.1.2.5 installed. These libraries differ only in their minor version because the 1.3 version is backwards compatible with the 1.2 version of the library, but 1.2 lacks the extra function.



    In my own example if I run readelf -d main | grep NEEDED I get:



     0x0000000000000001 (NEEDED) Shared library: [librandom.so.1]
    0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
    0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
    0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
    0x0000000000000001 (NEEDED) Shared library: [libc.so.6]


    So everything is linked against the major version numbers only.



    For my shared library I placed it in /usr/lib/ and added the symlinks:



    lrwxrwxrwx 1 root root 23 Feb 7 14:25 /usr/lib/librandom.so -> /usr/lib/librandom.so.1
    lrwxrwxrwx 1 root root 27 Feb 7 14:13 /usr/lib/librandom.so.1 -> /usr/lib/librandom.so.1.2.5
    -rw-r--r-- 1 root root 7696 Feb 7 14:00 /usr/lib/librandom.so.1.2.5


    Between the library maintainer, application developer and system administrator; who takes responsibility for avoiding this program crash?



    • Is it during installation of main that an error should be produced stating that the currently installed library's minor version is too low?

    • Should the program call a special function in the library to identify the version and check if the minor version is enough?

    • Is the library loader supposed to check all the symbols before the program starts running?

    • Have I misunderstood the version numbering or missed a setting to check the minor version?






    share|improve this question






















      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      I have a simple program called main:



      #include <iostream>
      #include "random.h"

      int main()

      std::cout << "The program has startedn";
      return get_another_random_number();



      The get_another_random_number() function is in a new version of a shared library, but only the old version is installed. The program begins running, but crashes at a later time when the lookup fails; e.g.



      $ ./main
      The program has started
      ./main: symbol lookup error: ./main: undefined symbol: _Z25get_another_random_numberv



      This will happen if, for example, librandom.so.1.3.1 contains a function called get_another_random_number(), but main is executed on a server that has only librandom.so.1.2.5 installed. These libraries differ only in their minor version because the 1.3 version is backwards compatible with the 1.2 version of the library, but 1.2 lacks the extra function.



      In my own example if I run readelf -d main | grep NEEDED I get:



       0x0000000000000001 (NEEDED) Shared library: [librandom.so.1]
      0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
      0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
      0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
      0x0000000000000001 (NEEDED) Shared library: [libc.so.6]


      So everything is linked against the major version numbers only.



      For my shared library I placed it in /usr/lib/ and added the symlinks:



      lrwxrwxrwx 1 root root 23 Feb 7 14:25 /usr/lib/librandom.so -> /usr/lib/librandom.so.1
      lrwxrwxrwx 1 root root 27 Feb 7 14:13 /usr/lib/librandom.so.1 -> /usr/lib/librandom.so.1.2.5
      -rw-r--r-- 1 root root 7696 Feb 7 14:00 /usr/lib/librandom.so.1.2.5


      Between the library maintainer, application developer and system administrator; who takes responsibility for avoiding this program crash?



      • Is it during installation of main that an error should be produced stating that the currently installed library's minor version is too low?

      • Should the program call a special function in the library to identify the version and check if the minor version is enough?

      • Is the library loader supposed to check all the symbols before the program starts running?

      • Have I misunderstood the version numbering or missed a setting to check the minor version?






      share|improve this question












      I have a simple program called main:



      #include <iostream>
      #include "random.h"

      int main()

      std::cout << "The program has startedn";
      return get_another_random_number();



      The get_another_random_number() function is in a new version of a shared library, but only the old version is installed. The program begins running, but crashes at a later time when the lookup fails; e.g.



      $ ./main
      The program has started
      ./main: symbol lookup error: ./main: undefined symbol: _Z25get_another_random_numberv



      This will happen if, for example, librandom.so.1.3.1 contains a function called get_another_random_number(), but main is executed on a server that has only librandom.so.1.2.5 installed. These libraries differ only in their minor version because the 1.3 version is backwards compatible with the 1.2 version of the library, but 1.2 lacks the extra function.



      In my own example if I run readelf -d main | grep NEEDED I get:



       0x0000000000000001 (NEEDED) Shared library: [librandom.so.1]
      0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
      0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
      0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
      0x0000000000000001 (NEEDED) Shared library: [libc.so.6]


      So everything is linked against the major version numbers only.



      For my shared library I placed it in /usr/lib/ and added the symlinks:



      lrwxrwxrwx 1 root root 23 Feb 7 14:25 /usr/lib/librandom.so -> /usr/lib/librandom.so.1
      lrwxrwxrwx 1 root root 27 Feb 7 14:13 /usr/lib/librandom.so.1 -> /usr/lib/librandom.so.1.2.5
      -rw-r--r-- 1 root root 7696 Feb 7 14:00 /usr/lib/librandom.so.1.2.5


      Between the library maintainer, application developer and system administrator; who takes responsibility for avoiding this program crash?



      • Is it during installation of main that an error should be produced stating that the currently installed library's minor version is too low?

      • Should the program call a special function in the library to identify the version and check if the minor version is enough?

      • Is the library loader supposed to check all the symbols before the program starts running?

      • Have I misunderstood the version numbering or missed a setting to check the minor version?








      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 7 at 22:04









      wally

      1185




      1185




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          You haven’t misunderstood version numbering, and this is indeed an area where symbol lookup typically comes up wanting.



          As to whose responsibility this is, I’d say that on modern systems it belongs to whomever builds the application, not the library: if you link the application with ld -z now (at least on GNU binutils), the dynamic linker will resolve all symbols at startup and fail early if any symbol is missing (so you don’t need to add manual checks of your own). You can enable this behaviour after a program is linked by exporting LD_BIND_NOW=1 to the environment (any non-empty value works, and this isn’t Linux-specific).



          This kind of problem is typically dealt with by package management systems: they keep extensive metadata describing version requirements for symbols, and generate the appropriate versioned dependencies. It’s also possible for library authors to help improve the situation, but it can take a lot of effort; see the GNU libc’s special version symbols (the GLIBC_... symbols that often turn up in error messages) and generally thorough handling of versioned symbols.






          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f422664%2fshared-library-minor-version-management%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote



            accepted










            You haven’t misunderstood version numbering, and this is indeed an area where symbol lookup typically comes up wanting.



            As to whose responsibility this is, I’d say that on modern systems it belongs to whomever builds the application, not the library: if you link the application with ld -z now (at least on GNU binutils), the dynamic linker will resolve all symbols at startup and fail early if any symbol is missing (so you don’t need to add manual checks of your own). You can enable this behaviour after a program is linked by exporting LD_BIND_NOW=1 to the environment (any non-empty value works, and this isn’t Linux-specific).



            This kind of problem is typically dealt with by package management systems: they keep extensive metadata describing version requirements for symbols, and generate the appropriate versioned dependencies. It’s also possible for library authors to help improve the situation, but it can take a lot of effort; see the GNU libc’s special version symbols (the GLIBC_... symbols that often turn up in error messages) and generally thorough handling of versioned symbols.






            share|improve this answer
























              up vote
              2
              down vote



              accepted










              You haven’t misunderstood version numbering, and this is indeed an area where symbol lookup typically comes up wanting.



              As to whose responsibility this is, I’d say that on modern systems it belongs to whomever builds the application, not the library: if you link the application with ld -z now (at least on GNU binutils), the dynamic linker will resolve all symbols at startup and fail early if any symbol is missing (so you don’t need to add manual checks of your own). You can enable this behaviour after a program is linked by exporting LD_BIND_NOW=1 to the environment (any non-empty value works, and this isn’t Linux-specific).



              This kind of problem is typically dealt with by package management systems: they keep extensive metadata describing version requirements for symbols, and generate the appropriate versioned dependencies. It’s also possible for library authors to help improve the situation, but it can take a lot of effort; see the GNU libc’s special version symbols (the GLIBC_... symbols that often turn up in error messages) and generally thorough handling of versioned symbols.






              share|improve this answer






















                up vote
                2
                down vote



                accepted







                up vote
                2
                down vote



                accepted






                You haven’t misunderstood version numbering, and this is indeed an area where symbol lookup typically comes up wanting.



                As to whose responsibility this is, I’d say that on modern systems it belongs to whomever builds the application, not the library: if you link the application with ld -z now (at least on GNU binutils), the dynamic linker will resolve all symbols at startup and fail early if any symbol is missing (so you don’t need to add manual checks of your own). You can enable this behaviour after a program is linked by exporting LD_BIND_NOW=1 to the environment (any non-empty value works, and this isn’t Linux-specific).



                This kind of problem is typically dealt with by package management systems: they keep extensive metadata describing version requirements for symbols, and generate the appropriate versioned dependencies. It’s also possible for library authors to help improve the situation, but it can take a lot of effort; see the GNU libc’s special version symbols (the GLIBC_... symbols that often turn up in error messages) and generally thorough handling of versioned symbols.






                share|improve this answer












                You haven’t misunderstood version numbering, and this is indeed an area where symbol lookup typically comes up wanting.



                As to whose responsibility this is, I’d say that on modern systems it belongs to whomever builds the application, not the library: if you link the application with ld -z now (at least on GNU binutils), the dynamic linker will resolve all symbols at startup and fail early if any symbol is missing (so you don’t need to add manual checks of your own). You can enable this behaviour after a program is linked by exporting LD_BIND_NOW=1 to the environment (any non-empty value works, and this isn’t Linux-specific).



                This kind of problem is typically dealt with by package management systems: they keep extensive metadata describing version requirements for symbols, and generate the appropriate versioned dependencies. It’s also possible for library authors to help improve the situation, but it can take a lot of effort; see the GNU libc’s special version symbols (the GLIBC_... symbols that often turn up in error messages) and generally thorough handling of versioned symbols.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 7 at 22:25









                Stephen Kitt

                142k22308369




                142k22308369






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f422664%2fshared-library-minor-version-management%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?