Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Linux stata bug (libpng) on newer openSUSE (possibly other) distributions

    I have encountered the following problem on the newest version of openSUSE (13.1). It does not occur on openSUSE 12.2 or older, nor does it occur on RHEL5 or 6 (haven't tried Ubuntu or similar ones): icons in the UI are gone (see screenshot attached)

    Error message at the console:

    Code:
    (xstata:1704): Gtk-WARNING **: Error loading theme icon 'dialog-question' for stock: Fatal error reading PNG image file: bad parameters to zlib
    Installed PNG libraries:

    Code:
    > rpm -qa | grep libpng
    libpng16-16-32bit-1.6.6-12.1.x86_64
    libpng16-16-1.6.6-12.1.x86_64
    libpng12-0-32bit-1.2.50-6.1.2.x86_64
    libpng12-0-1.2.50-6.1.2.x86_64
    libpng15-15-1.5.13-3.1.1.x86_64
    On a working openSUSE 12.2 system:
    Code:
    > rpm -qa | grep libpng
    libpng14-14-32bit-1.4.11-2.5.1.x86_64
    libpng14-14-1.4.11-2.5.1.x86_64
    libpng12-0-1.2.49-2.1.2.x86_64
    and on a RHEL6 system:
    Code:
    > rpm -qa | grep libpng
    libpng-devel-1.2.49-1.el6_2.x86_64
    libpng-1.2.49-1.el6_2.x86_64
    Searching on the internet, most point at newer versions of libpng16 being the problem, but my main desktops are MATE and Gnome, and they make extensive use of libpng16, without any issues. Adjusting LD_LIBRARY_PATH does not work. Uninstalling libpng16 is not an option (nearly the entire system is linked to it). Stata is up to date (see the screenshot of the problem).

    Any solutions? If it is a broken libpng library, one would expect more widespread problems.
    The problem : all icons are replaced with exclamation marks, png issues at the command line.

  • #2
    Please contact Stata TechnicalServices regarding this. They will gather more information from you about your system to track down the cause of this problem. When we find a solution, I will post the resolution here.

    Kevin Crow
    StataCorp

    Comment


    • #3
      I corresponded with Peter Fuschich of the Stata Technical Department, and his solution, which I'm posting here, worked. I subsequently scripted and slightly modified his solution somewhat (I made a drop-in replacement script, rather than an additional script), and put it up on Bitbucket for anybody who wishes to also run it. The Bitbucket solution can be found at https://bitbucket.org/vilhuberl/stata-png-fix , below is Peter's original solution:

      This is an issue we have encountered with some of the latest Linux distributions. We have come up with a work around for this issue. The fix does
      include recompiling some libraries, so do not attempt unless you feel confident in doing so.

      First, make sure you have a development environment installed:

      $ sudo yum install gcc

      When that is complete, you will need to download the source code for two
      libraries: zlib and libpng.

      ************************************************** ************************
      $ cd /tmp
      $ umask 0002
      $ mkdir build
      $ cd build
      $ wget http://downloads.sourceforge.net/pro...b-1.2.3.tar.gz
      $ wget http://downloads.sourceforge.net/pro...g-1.6.2.tar.gz
      $ tar zxf zlib-1.2.3.tar.gz
      $ cd zlib-1.2.3
      $ export CFLAGS="-fPIC"
      $ ./configure --prefix=/usr/local/zlib-1.2.3
      $ sudo make install
      $ cd ..
      $ tar zxf libpng-1.6.2.tar.gz
      $ cd libpng-1.6.2
      $ export CFLAGS="-I/usr/local/zlib-1.2.3/include -fPIC"
      $ export LDFLAGS="-L/usr/local/zlib-1.2.3/lib"
      $ ./configure --prefix=/usr/local/libpng-1.6.2
      $ vi ./scripts/pnglibconf.dfa (comment out the line "@# include <zlib.h>")
      --line 235 in my text editor
      $ sudo make install
      ************************************************** ************************

      Now that you have finished building the libraries, you must instruct Stata on
      how to use them properly. Since you don't want these libraries to interfere
      with normal system operations, I would suggest writing either a wrapper or an
      alias for the Stata executables, something like this:

      -----------------begin stata wrapper----------------
      #!/bin/bash

      flavor="$1"
      shift 1

      case "$flavor" in
      "c") LD_LIBRARY_PATH=/usr/local/zlib-1.2.3/lib:/usr/local/libpng-1.6.2/lib
      exec /usr/local/stata13/stata
      ;;
      "x") LD_LIBRARY_PATH=/usr/local/zlib-1.2.3/lib:/usr/local/libpng-1.6.2/lib
      exec /usr/local/stata13/xstata $* > /dev/null 2>&1
      ;;
      "se") LD_LIBRARY_PATH=/usr/local/zlib-1.2.3/lib:/usr/local/libpng-1.6.2/lib
      exec /usr/local/stata13/stata-se
      ;;
      "xse") LD_LIBRARY_PATH=/usr/local/zlib-1.2.3/lib:/usr/local/libpng-1.6.2/lib
      exec /usr/local/stata13/xstata-se $* > /dev/null 2>&1
      ;;
      "mp") LD_LIBRARY_PATH=/usr/local/zlib-1.2.3/lib:/usr/local/libpng-1.6.2/lib
      exec /usr/local/stata13/stata-mp
      ;;
      "xmp") LD_LIBRARY_PATH=/usr/local/zlib-1.2.3/lib:/usr/local/libpng-1.6.2/lib
      exec /usr/local/stata13/xstata-mp $* > /dev/null 2>&1
      ;;
      esac

      echo "stata: usage: stata {c|x|se|xse|mp|xmp} [stata options]" 1>&2
      exit 1
      -------------------end stata wrapper----------------


      You can copy the above script to a file named 'stata', set its permissions to
      be executable, and place it in a directory located in your $PATH environment
      variable:

      $ chmod 755 stata
      $ sudo mv stata /usr/local/bin

      Now, when you want to launch the GUI version of Stata/MP, for example, type:

      $ stata xmp

      To launch the console version of Stata/MP, type:

      $ stata mp

      Just typing 'stata' without arguments should give you a quick syntax diagram.
      ************************************************** ************************

      Or, you can create an alias to launch the version of Stata you are licensed to
      use. For example, if your license is for Stata/IC, then you could use the
      following Alias placed in your $PATH environment variable:

      alias xstatamp='LD_LIBRARY_PATH=/usr/local/zlib-1.2.3/lib:/usr/local/libpng-1.6.2/lib/usr/local/stata13/xstata'


      Comment


      • #4
        Thanks a lot for this fix.

        Two things:
        1. I can confirm this fixes the broken icon problem on Fedora 24.
        2. Unfortunately, this break any stata functionality that requires more current versions of libpng (e.g. the stata add-on package markdoc's latex compile functionality):
        Code:
        . markdoc stata_latex, export(pdf) replace install markup(latex) texmaster mathjax printer("/usr/bin/pdflatex") noisily
        
        Compiling LaTeX to PDF
        "/usr/bin/pdflatex" -jobname "stata_latex" "/tmp/St10464.000001"
        
        /usr/bin/pdflatex: relocation error: /usr/bin/pdflatex: symbol png_set_option, version PNG16_0 not defined in file libpng16.so.16 with link time reference
        MarkDoc could not produce stata_latex.pdf
        Conclusion: the fix (thanks again) may work in most cases but is not a total solution to stata's ongoing libpng problem.

        Comment


        • #5
          Three years and one major release later, we are still waiting for a proper fix. Will Stata 15 still depend on libpng 1.6.2? The world wonders.

          Comment


          • #6
            my a little concise version of larsvilhuber's wrapper script

            Code:
            #!/bin/bash
            
            set -o nounset
            
            progdir=$(dirname "$(readlink -f "$0")")
            
            export LD_LIBRARY_PATH=$progdir
            PATH="$PATH:$progdir"
            
            x11=''
            var=''
            
            declare -a rest=
            
            while [[ $# -ne 0 ]];do
              case "$1" in
                x) x11=x ;;
                se) var=-se ;;
                mp) var=-mp ;;
                sm) var=-sm ;;
                --) shift; rest+=("$@");break;;
                -h) echo "$0 [x] [|se|sm|mp] [--] [arguments to stata] ..." >&2; exit;;
                *)  rest+=("$1");;
              esac
              shift
            done
            
            exec "$x11"stata"$var" "${rest[@]}"
            This script assumes you copied libz and libpng libraries into stata's directory, which makes the program more portable across Linux distributions.

            launching examples:

            Code:
            $ run-stata x se "extra args to stata" # "x" means gui, "se" means standard edition, you can also use "sm", "mp" or nothing.
            $ run-stata mp -- x # x will be passed to stata, not to the wrapper, which will invoke the command line version.
            Last edited by Leon Meow; 21 Mar 2017, 06:52.

            Comment


            • #7
              Thanks for this fix. I can confirm that this script fixed the broken icon problem in Ubuntu 16.10. I had to install zlib with development support first:
              Code:
              sudo apt-get install zlib1g-dev
              after that, it worked fine.

              Comment


              • #8
                Thanks too for this fix. The problem also occured in Fedora 25 (Stata mp version 12). It works fine now after compiling zlib and libpng and loading this libraries via your stata wrapper above.

                Comment


                • #9
                  Hi,

                  I'm new with Linux and I'm also experiencing same no-icon stuff. I'm getting an error on line 28 when running "stata x mp" -> "error line 28: xstata mp: not found" with Leo's approach. Am I missing something? I've just copied the script to my own "/usr/local/bin/" and copied both libpng libz to the stata folder. I'm running ubuntu 17.04 with stata mp 14.0. Hope you help to get me through this. Thnx!!!
                  Last edited by Ike Wolf; 11 Dec 2017, 12:55.

                  Comment


                  • #10
                    Originally posted by Ike Wolf View Post
                    Hi,

                    I'm new with Linux and I'm also experiencing same no-icon stuff. I'm getting an error on line 28 when running "stata x mp" -> "error line 28: xstata mp: not found" with Leo's approach. Am I missing something? I've just copied the script to my own "/usr/local/bin/" and copied both libpng libz to the stata folder. I'm running ubuntu 17.04 with stata mp 14.0. Hope you help to get me through this. Thnx!!!
                    Do you have Stata on your PATH? (e.g. If you type "which stata" or "which xstata" what is the output?) I always have this issue on Linux; a slightly modified version of larsvilhuber's approach (here is his original, though the link is also in his post: https://bitbucket.org/vilhuberl/stata-png-fix) is what does it for me.

                    Comment


                    • #11
                      Hi there, can you explain the steps to write the wrapper in a layman language please? I am stuck at the step and cannot get Stata to show the icons. Really appreciate it.

                      Comment


                      • #12
                        Originally posted by Alessio Tomasino View Post
                        Hi there, can you explain the steps to write the wrapper in a layman language please? I am stuck at the step and cannot get Stata to show the icons. Really appreciate it.
                        The easiest way to get the icons is to use larsvilhuber's script. Download the script from https://bitbucket.org/vilhuberl/stata-png-fix

                        Now go to the folder where you downloaded the script and extract its contents (you can use either zip or tar).

                        Change directory to the newly extracted folder. Make sure that your user has sudo privileges (i.e., make sure your user is in the sudoers list). Once your user has admin privileges run the following from within the folder where you extracted the larsvilhuber's solution:

                        Code:
                        compile-stata-png-fix.sh
                        During the installation process, you will have to press ENTER twice (I seem to recall the script simply lets you know that you can stop the installation process with Ctrl+c, when the script hits that bit you simply press ENTER). You will have to enter your password too (in order to get the libraries we are trying to install).

                        The script finalises with four suggestions for four new symlinks. You really need only one, though (assuming that you only use one version of Stata). For example, if you use Stata-SE you could do:

                        Code:
                        sudo ln -sf /usr/local/stata-png-fix/stata-png-fixed.sh /usr/local/bin/xstata-se
                        Now, provided that /usr/local/bin is in your $PATH, you should be able to just type "xstata-se" to get Stata with icons. If you installed Stata in /usr/local/stata then you should not need to change anything. However, if like me you installed Stata in a different location you will have to change the directory to which the symlink points at (simply by replacing /usr/local/stata with whatever you need, like /opt/stata13).

                        Now if you run in a terminal "xstata-se" (the name of the symlink in /usr/local/bin) you should get Stata with icons. Hope this helps.

                        Comment


                        • #13
                          Originally posted by Alessio Tomasino View Post
                          Hi there, can you explain the steps to write the wrapper in a layman language please? I am stuck at the step and cannot get Stata to show the icons. Really appreciate it.
                          Alessio Tomasino's request for an explanation is well justified! I just went through this in an Ubuntu-18.04 system and I can explain what's going on.

                          I may not have "layman's terms" to explain, but I have novice Linux user terms, and that's probably what you need. The program that Stata delivers to you is incomplete. This is intentional. It is true of many programs because programs depend on "shared libraries" that are offered by the OS. Think of, say, a printer routine. We don't (anymore) want every program to provide its own printer driver for every program. We want one OS level package to handle that. In this case, Stata is looking for old versions of 2 libraries, zlib and png. Stata thinks it finds what it needs, but it is wrong. That's why you don't see icons. Your computer has newer versions of the support libraries than Stata expects. It appears to me Stata assumes you have a version of zlib from 2002. Why? I have no idea.

                          I don't think the right thing is to use the script suggested in the previous post. That installer runs as the root user. That's insecure. Running somebody elses's script as root is a bad habit in system administration. Dangerous. Literally, you give the permission to change *anything* on your file system to a stranger. Don't..

                          The #3 post above offers Peter Fuschich's sequence. That's a pretty clear step by step approach. Basically,
                          1. Download old copies of zlib and png library software (source code), and
                          2. then build (compile) them, and install them in an "out of the way" place.
                          3. Tell Stata to use those libraries from the "out of the way" place.

                          I've done this today, it still works in Ubuntu 18.04.

                          About zlib and libpng. Most GNU libraries follow same scheme, where you download a compressed archive (*.tar.gz), then open that up, and then run

                          $ configure --prefix=/user/local/put-something-here
                          $ make
                          $ sudo make install

                          "/usr/local/put-something-here" should be a directory name. Installing in that folder requires the "sudo" in line 3. I suggest instead you ought to do

                          $ configure --prefix=$HOME/statalibs
                          $ make
                          $ make install

                          Because I put the libs in /home/pauljohn/statalibs, I do not need to use a root password. No "sudo" in line 3. ($HOME means /home/pauljohn for me)

                          In the libpng build process described in #3, there's a very unusual wrinkle. That's worth the price of admission by itself. The part where you set the CFLAG and LDFLAG is not too unusual. But the part that suggests we need to pause between configure and make and hand edit one of the files is unusual. I've not seen this, ever. I've compiled 1000s of packages and I've never seen this. The intent is clear, though. Make sure libpng uses the zlib you just created, not the one from the OS. I'm pretty sure the more usual approach would be to alter the configure statement, but I've fiddled with it quite a bit and can't make it generate a proper libpng shared library.

                          The other wrinkles in #3 concern a security setting in the modern compiler, "-fPIC".

                          The zlib and png source packages are still available on sourceforge. The first time I tried, wget failed. I suspect the security system wanted me to visit in a browser:

                          https://sourceforge.net/projects/lib...les/zlib/1.2.3
                          https://sourceforge.net/projects/lib...releases/1.6.2

                          Choose the tar.gz ones and the install steps in #3 will work just right.

                          Anyway, to run Stata successfully, you need to tell Stata where to find your newly installed libraries. This is done by setting LD_LIBRARY_PATH. If your stata happens to be installed in /usr/local/stata15, for example:

                          $ LD_LIBRARY_PATH=$HOME/statalibs/lib:$LD_LIBRARY_PATH /usr/local/stata15/xstata-se

                          The icons are fine after this.

                          In previous posts above there are some suggestions for a launcher script. For my eye, they are non-standard and unnecessary. I will think on what to do instead. I'll probably keep it simple, probably just put a one liner in a file, like

                          LD_LIBRARY_PATH=/home/pauljohn/statalibs/lib:$LD_LIBRARY_PATH usr/local/stata15/xstata-se $1

                          So far, that's working fine to launch Stata. Again, I'm avoiding the "you must be root" problem by not installing into /usr/local/bin. (chmod +x $HOME/bin/xstata will be needed).

                          Oh, well, I hope that helps you understand it better. This one offers a pretty good learning experience.

                          And, by the way, even though the icons show correctly and most of the error messages that show in the terminal are silenced, I still see quite a few of these:



                          ** (xstata-se:13940): WARNING **: 02:17:34.190: Invalid borders specified for theme pixmap:
                          /usr/share/themes/Breeze/gtk-2.0/../assets/line-h.png,
                          borders don't fit within the image

                          ** (xstata-se:13940): WARNING **: 02:17:34.190: invalid source position for vertical gradient

                          This is a warning about the fact that there is something wrong in an old theme that is being used. I say "old" because it is based on gtk-2.0, which is, well, being phased out. Most programs have been upgraded to gtk-3.0, but not Stata. Nobody's going to go back and try to fix the old themes, so some noise in the terminal seems to be unavoidable.

                          Comment


                          • #14
                            @Stata : wouldn't it be time to fix this once and for all? For instance, by packaging a Stata-specific set of libraries that Stata knows to reference, the same way the JRE is packaged with Stata?

                            Comment


                            • #15
                              I have the same problem with Stata 15 on Linux Mint 19. I tried the script but get an error message.
                              I got the script from here: https://bitbucket.org/vilhuberl/stata-png-fix/overview
                              When I now run the code I receive the following error:
                              Code:
                              Building in /tmp/tmp.cjhFnDUJS5
                              --2018-07-03 21:07:57--  http://downloads.sourceforge.net/project/libpng/zlib/1.2.3/zlib-1.2.3.tar.gz
                              Resolving downloads.sourceforge.net (downloads.sourceforge.net)... 216.105.38.13
                              Connecting to downloads.sourceforge.net (downloads.sourceforge.net)|216.105.38.13|:80... connected.
                              HTTP request sent, awaiting response... 302 Found
                              Location: https://netcologne.dl.sourceforge.net/project/libpng/zlib/1.2.3/zlib-1.2.3.tar.gz [following]
                              --2018-07-03 21:07:57--  https://netcologne.dl.sourceforge.net/project/libpng/zlib/1.2.3/zlib-1.2.3.tar.gz
                              Resolving netcologne.dl.sourceforge.net (netcologne.dl.sourceforge.net)... 78.35.24.46, 2001:4dd0:1234:6::5f
                              Connecting to netcologne.dl.sourceforge.net (netcologne.dl.sourceforge.net)|78.35.24.46|:443... connected.
                              HTTP request sent, awaiting response... 200 OK
                              Length: 496597 (485K) [application/x-gzip]
                              Saving to: ‘zlib-1.2.3.tar.gz’
                              
                              zlib-1.2.3.tar.gz   100%[===================>] 484,96K   861KB/s    in 0,6s    
                              
                              2018-07-03 21:07:58 (861 KB/s) - ‘zlib-1.2.3.tar.gz’ saved [496597/496597]
                              
                              --2018-07-03 21:07:58--  http://downloads.sourceforge.net/project/libpng/libpng16/older-releases/1.6.2/libpng-1.6.2.tar.gz
                              Resolving downloads.sourceforge.net (downloads.sourceforge.net)... 216.105.38.13
                              Connecting to downloads.sourceforge.net (downloads.sourceforge.net)|216.105.38.13|:80... connected.
                              HTTP request sent, awaiting response... 302 Found
                              Location: https://datapacket.dl.sourceforge.net/project/libpng/libpng16/older-releases/1.6.2/libpng-1.6.2.tar.gz [following]
                              --2018-07-03 21:07:59--  https://datapacket.dl.sourceforge.net/project/libpng/libpng16/older-releases/1.6.2/libpng-1.6.2.tar.gz
                              Resolving datapacket.dl.sourceforge.net (datapacket.dl.sourceforge.net)... 185.152.64.70
                              Connecting to datapacket.dl.sourceforge.net (datapacket.dl.sourceforge.net)|185.152.64.70|:443... connected.
                              HTTP request sent, awaiting response... 200 OK
                              Length: 1256016 (1,2M) [application/x-gzip]
                              Saving to: ‘libpng-1.6.2.tar.gz’
                              
                              libpng-1.6.2.tar.gz 100%[===================>]   1,20M   834KB/s    in 1,5s    
                              
                              2018-07-03 21:08:01 (834 KB/s) - ‘libpng-1.6.2.tar.gz’ saved [1256016/1256016]
                              
                              Checking for gcc...
                              Building static library libz.a version 1.2.3 with gcc.
                              Checking for unistd.h... No.
                              Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()
                              Checking for snprintf() in stdio.h... No.
                                WARNING: snprintf() not found, falling back to sprintf(). zlib
                                can build but will be open to possible buffer-overflow security
                                vulnerabilities.
                              Checking for return value of sprintf()... No.
                                WARNING: apparently sprintf() does not return a value. zlib
                                can build but will be open to possible string-format security
                                vulnerabilities.
                              Checking for errno.h... No.
                              Checking for mmap support... No.
                              gcc -fPIC -DNO_snprintf -DHAS_sprintf_void -DNO_ERRNO_H   -c -o example.o example.c
                              example.c:8:10: fatal error: stdio.h: No such file or directory
                               #include <stdio.h>
                                        ^~~~~~~~~
                              compilation terminated.
                              <builtin>: recipe for target 'example.o' failed
                              make: *** [example.o] Error 1
                              Ready to install in /usr/local/stata-png-fix (ctrl-c to end)

                              Comment

                              Working...
                              X