Giter VIP home page Giter VIP logo

Comments (6)

davispuh avatar davispuh commented on August 17, 2024

Not sure why this happens but basically in util/Mutex.cpp#186 CriticalSection::lock is called with true as errorCheck and pthread_mutex_lock returns EINVAL

from virtualgl.

dcommander avatar dcommander commented on August 17, 2024

There seem to be a certain class of issues that occur in Arch Linux and nothing else. As with the VLC issue, I am unable to reproduce this on any of the O/S's I have installed, and I am not in a good position to support Arch Linux, because none of my paying customers use it (and frankly, Arch is not the easiest thing in the world to install.)

from virtualgl.

dcommander avatar dcommander commented on August 17, 2024

I mean, you can look at the code in faker.cpp and see clearly that CriticalSection::lock() is called with errorCheck=false. I can see no rational explanation for this. It would help if you built VirtualGL with debugging symbols and posted a backtrace with line numbers.

from virtualgl.

davispuh avatar davispuh commented on August 17, 2024

I was looking into this and I really didn't understood why pthread_mutex_lock fails so I gave up.

#0  0x00007f43de52e5f8 in raise () from /usr/lib/libc.so.6
#1  0x00007f43de52fa7a in abort () from /usr/lib/libc.so.6
#2  0x00007f43de900f1d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libvglfaker.so
#3  0x00007f43de900316 in __cxxabiv1::__terminate(void (*)()) () from /usr/lib/libvglfaker.so
#4  0x00007f43de900361 in std::terminate() () from /usr/lib/libvglfaker.so
#5  0x00007f43de900468 in __cxa_throw () from /usr/lib/libvglfaker.so
#6  0x00007f43de8fe8bc in vglutil::CriticalSection::lock (this=this@entry=0x7f43deb4ca20 <vglfaker::GlobalCriticalSection::instanceMutex>, errorCheck=errorCheck@entry=true)
    at /mnt/GitHub/virtualgl/util/Mutex.cpp:187
#7  0x00007f43de8af234 in vglutil::CriticalSection::SafeLock::SafeLock (errorCheck_=true, cs_=..., this=<synthetic pointer>)
    at /mnt/GitHub/virtualgl/include/Mutex.h:68
#8  vglfaker::GlobalCriticalSection::getInstance () at /mnt/GitHub/virtualgl/server/GlobalCriticalSection.h:42
#9  vglfaker::GlobalCleanup::~GlobalCleanup (this=<optimized out>, __in_chrg=<optimized out>) at /mnt/GitHub/virtualgl/server/faker.cpp:86
#10 0x00007f43de5312ef in __cxa_finalize () from /usr/lib/libc.so.6
#11 0x00007f43de8ad743 in __do_global_dtors_aux () from /usr/lib/libvglfaker.so
#12 0x00007fff75a59990 in ?? ()
#13 0x00007f43ded6a867 in _dl_fini () from /lib64/ld-linux-x86-64.so.2
Backtrace stopped: frame did not save the PC

Basically in globalMutex.lock(false) it first calls vglfaker::GlobalCriticalSection::getInstance() and there vglutil::CriticalSection::SafeLock l(instanceMutex) is executed because instance is NULL
next

SafeLock(CriticalSection &cs_, bool errorCheck_=true) : cs(cs_),
                        errorCheck(errorCheck_)
                    {
                        cs.lock(errorCheck);
                    }

can see that errorCheck=true.

this patch prevents crash, but doesn't solve why locking fails...

diff --git a/server/GlobalCriticalSection.h b/server/GlobalCriticalSection.h
index 32d0149..0fac747 100644
--- a/server/GlobalCriticalSection.h
+++ b/server/GlobalCriticalSection.h
@@ -39,7 +39,7 @@ namespace vglfaker
                        {
                                if(instance==NULL)
                                {
-                                       vglutil::CriticalSection::SafeLock l(instanceMutex);
+                                       vglutil::CriticalSection::SafeLock l(instanceMutex, false);
                                        if(instance==NULL) instance=new GlobalCriticalSection;
                                }
                                return instance;

ArchLinux isn't that different from other distributions, but it always have latest libraries (there are updates daily) and thus issues (and other library bugs) there show up sooner than elsewhere.
Currently all Arch Linux libraries are compiled with GCC > 5.0 (it uses new ABI) and newest glibc.
So this bug it might be related to GCC version and optimization/compile flags.

I'm building like this

cmake -DCMAKE_BUILD_TYPE=Debug \
      -DCMAKE_INSTALL_PREFIX=/usr/share \
      -DTJPEG_INCLUDE_DIR=/usr/include \
      -DTJPEG_LIBRARY=/usr/lib/libturbojpeg.so \
      -DVGL_LIBDIR=/usr/lib \
      -DVGL_BINDIR=/usr/bin \
      -DVGL_DOCDIR=/usr/share/doc/virtualgl

and example of compile command

/usr/bin/c++   -DFAKEXCB -DUSEXV -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D__APPNAME=\"VirtualGL\" -D__BUILD=\"20151202d\" -D__VERSION=\"2.4.91\" -Dvglfaker_EXPORTS -I/mnt/GitHub/virtualgl/include -I/mnt/GitHub/virtualgl/build/src/build/server -I/mnt/GitHub/virtualgl/server -I/mnt/GitHub/virtualgl/server/../common -I/mnt/GitHub/virtualgl/server/fltk  -march=native -O2 -pipe -fstack-protector-strong -g -fvar-tracking-assignments  -g -fPIC   -static-libgcc -fPIC -o CMakeFiles/vglfaker.dir/faker.cpp.o -c /mnt/GitHub/virtualgl/server/faker.cpp

from virtualgl.

dcommander avatar dcommander commented on August 17, 2024

I just checked in a commit that should fix this. I don't know why pthread_mutex_lock() fails in the global destructor under these circumstances, but I have seen that issue before, which is why the calls to globalMutex.lock()/unlock() in GlobalCleanup::~GlobalCleanup() specify errorCheck=false. The SafeLock instance in GlobalCriticalSection doesn't do that (oversight on my part), which is the source of the error. I think the correct course of action is to simply ignore globalMutex in ~GlobalCleanup() if it hasn't been instantiated yet (if that mutex hasn't been used by the time the global destructor is called, then VirtualGL hasn't started any threads, so there is no need for a global mutex at all.)

from virtualgl.

davispuh avatar davispuh commented on August 17, 2024

awesome 👍 , works fine, thanks.

from virtualgl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.