naelstrof / slop

slop (Select Operation) is an application that queries for a selection from the user and prints the region to stdout.
Other
853 stars 58 forks source link

Segmentation fault in slop 0b66444a on Ubuntu 16.04 using nvidia-381.22 #81

Closed dllu closed 7 years ago

dllu commented 7 years ago

Today I cloned and compiled the latest version 0b66444ad43c6a2c9b5da399d8ce2e2568f56292

> git clone $slop
> cd slop
> mkdir build
> cd build
> cmake -DCMAKE_BUILD_TYPE=Debug ..
> make
> cd ../bin
> ./slop
fish: “./slop” terminated by signal SIGSEGV (Address boundary error)
> valgrind ./slop
==2835== Memcheck, a memory error detector
==2835== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==2835== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==2835== Command: ./slop
==2835== 
==2835== Jump to the invalid address stated on the next line
==2835==    at 0x0: ???
==2835==    by 0x85365C1: init (dlerror.c:177)
==2835==    by 0x85365C1: _dlerror_run (dlerror.c:129)
==2835==    by 0x8536087: dlsym (dlsym.c:70)
==2835==    by 0x8BCA12E: ??? (in /usr/lib/nvidia-381/libGLdispatch.so.0)
==2835==    by 0x8BCA8B8: ??? (in /usr/lib/nvidia-381/libGLdispatch.so.0)
==2835==    by 0x40104A9: call_init.part.0 (dl-init.c:58)
==2835==    by 0x40105FA: call_init (dl-init.c:30)
==2835==    by 0x40105FA: _dl_init (dl-init.c:120)
==2835==    by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==2835==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==2835== 
==2835== 
==2835== Process terminating with default action of signal 11 (SIGSEGV)
==2835==  Bad permissions for mapped region at address 0x0
==2835==    at 0x0: ???
==2835==    by 0x85365C1: init (dlerror.c:177)
==2835==    by 0x85365C1: _dlerror_run (dlerror.c:129)
==2835==    by 0x8536087: dlsym (dlsym.c:70)
==2835==    by 0x8BCA12E: ??? (in /usr/lib/nvidia-381/libGLdispatch.so.0)
==2835==    by 0x8BCA8B8: ??? (in /usr/lib/nvidia-381/libGLdispatch.so.0)
==2835==    by 0x40104A9: call_init.part.0 (dl-init.c:58)
==2835==    by 0x40105FA: call_init (dl-init.c:30)
==2835==    by 0x40105FA: _dl_init (dl-init.c:120)
==2835==    by 0x4000CF9: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==2835== 
==2835== HEAP SUMMARY:
==2835==     in use at exit: 0 bytes in 0 blocks
==2835==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==2835== 
==2835== All heap blocks were freed -- no leaks are possible
==2835== 
==2835== For counts of detected and suppressed errors, rerun with: -v
==2835== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
fish: “valgrind ./slop” terminated by signal SIGSEGV (Address boundary error)

I'm using:

nvidia-381/xenial,now 381.22-0ubuntu0~gpu16.04.2 amd64

Graphics card is an NVIDIA Geforce GTX 1070:

> lspci -v | grep -A 11 VGA
01:00.0 VGA compatible controller: NVIDIA Corporation Device 1b81 (rev a1) (prog-if 00 [VGA controller])
    Subsystem: ASUSTeK Computer Inc. Device 85a0
    Flags: bus master, fast devsel, latency 0, IRQ 134
    Memory at dc000000 (32-bit, non-prefetchable) [size=16M]
    Memory at c0000000 (64-bit, prefetchable) [size=256M]
    Memory at d0000000 (64-bit, prefetchable) [size=32M]
    I/O ports at e000 [size=128]
    [virtual] Expansion ROM at dd000000 [disabled] [size=512K]
    Capabilities: <access denied>
    Kernel driver in use: nvidia
    Kernel modules: nvidiafb, nouveau, nvidia_381, nvidia_381_drm

Here's my screen configuration:

> xrandr
Screen 0: minimum 8 x 8, current 6000 x 3840, maximum 32767 x 32767
DVI-D-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 disconnected (normal left inverted right x axis y axis)
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-0 connected primary 3840x2160+0+840 (normal left inverted right x axis y axis) 527mm x 296mm
   3840x2160     60.00*+  29.98  
   2560x1440     59.95  
   2048x1280     59.96  
   1920x1200     59.88  
   1920x1080     60.00    60.00    59.94    50.00    23.97    60.00    50.04  
   1600x1200     60.00  
   1600x900      60.00  
   1280x1024     75.02    60.02  
   1280x720      60.00    59.94    50.00  
   1152x864      75.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.94    59.93  
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 connected 2160x3840+3840+0 left (normal left inverted right x axis y axis) 527mm x 296mm
   3840x2160     60.00*+  29.98  
   2560x1440     59.95  
   2048x1280     59.96  
   1920x1200     59.88  
   1920x1080     60.00    60.00    59.94    50.00    23.97    60.00    50.04  
   1600x1200     60.00  
   1600x900      60.00  
   1280x1024     75.02    60.02  
   1280x720      60.00    59.94    50.00  
   1152x864      75.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.94    59.93  
DP-3 disconnected (normal left inverted right x axis y axis)

T__T

naelstrof commented 7 years ago

So your video drivers are crashing, unfortunately Nvidia drivers source is closed so I don't know what's going on. My machine is using nvidia with the exact same drivers (381.22), but I cannot reproduce the error. There's similar troubles in #80, could you give me the output of glxinfo | grep version? This guy has a similar issue, but fixed it with a environment variable: https://github.com/naelstrof/maim/issues/99#issuecomment-308205196 Also, could you see if this commit makes any difference? badecc298be64aa1c3417eb694182a23ebc3515d

naelstrof commented 7 years ago

Oh and using git bisect to find the commit that caused the bug would help too.

dllu commented 7 years ago

Here's the output of glxinfo | grep version:

> glxinfo | grep version
server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
OpenGL core profile version string: 4.5.0 NVIDIA 381.22
OpenGL core profile shading language version string: 4.50 NVIDIA
OpenGL version string: 4.5.0 NVIDIA 381.22
OpenGL shading language version string: 4.50 NVIDIA
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 381.22
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
    GL_EXT_shader_implicit_conversions, GL_EXT_shader_integer_mix,

As for that guy's environment variable, it didn't help.

> env MESA_DEBUG=1 ./slop
fish: “env MESA_DEBUG=1 ./slop” terminated by signal SIGSEGV (Address boundary error)
> env MESA_GL_VERSION_OVERRIDE="3.0" ./slop
fish: “env MESA_GL_VERSION_OVERRIDE="3…” terminated by signal SIGSEGV (Address boundary error

In fact, the segmentation fault happens with slop -v as well.

According to git bisect,

3b19860795514db6eada52603a57b40044f2a655 is the first bad commit
> git checkout 3b19860795514db6eada52603a57b40044f2a655
Previous HEAD position was 9019211... Fixed a bug where an InputOnly window would be selected.
HEAD is now at 3b19860... Switched to using a POSIX compliant argument parser. This will break scripts! sorry
> cmake -DCMAKE_BUILD_TYPE=Debug ..; and make; and ../bin/slop
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dllu/Proj/slop/build
Scanning dependencies of target slopy
[  6%] Building CXX object CMakeFiles/slopy.dir/src/mouse.cpp.o
[ 12%] Building CXX object CMakeFiles/slopy.dir/src/keyboard.cpp.o
[ 18%] Building CXX object CMakeFiles/slopy.dir/src/x.cpp.o
[ 25%] Building CXX object CMakeFiles/slopy.dir/src/slopstates.cpp.o
[ 31%] Building CXX object CMakeFiles/slopy.dir/src/framebuffer.cpp.o
[ 37%] Building CXX object CMakeFiles/slopy.dir/src/resource.cpp.o
[ 43%] Building C object CMakeFiles/slopy.dir/src/gl_core_3_3.c.o
[ 50%] Building CXX object CMakeFiles/slopy.dir/src/shader.cpp.o
[ 56%] Building CXX object CMakeFiles/slopy.dir/src/window.cpp.o
[ 62%] Building CXX object CMakeFiles/slopy.dir/src/slop.cpp.o
[ 68%] Building CXX object CMakeFiles/slopy.dir/src/rectangle.cpp.o
[ 75%] Building CXX object CMakeFiles/slopy.dir/src/xshaperectangle.cpp.o
[ 81%] Building CXX object CMakeFiles/slopy.dir/src/glrectangle.cpp.o
[ 87%] Linking CXX shared library libslopy.so
[ 87%] Built target slopy
Scanning dependencies of target slop
[ 93%] Building CXX object CMakeFiles/slop.dir/src/main.cpp.o
[100%] Linking CXX executable ../bin/slop
[100%] Built target slop
fish: “and ../bin/slop” terminated by signal SIGSEGV (Address boundary error)
> git checkout 90192110ecfad40ef08c5a42a6d6370c6cc5b929
Previous HEAD position was 3b19860... Switched to using a POSIX compliant argument parser. This will break scripts! sorry
HEAD is now at 9019211... Fixed a bug where an InputOnly window would be selected.
> cmake -DCMAKE_BUILD_TYPE=Debug ..; and make; and ../bin/slop
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dllu/Proj/slop/build
Scanning dependencies of target slopy
[  5%] Building CXX object CMakeFiles/slopy.dir/src/mouse.cpp.o
[ 11%] Building CXX object CMakeFiles/slopy.dir/src/keyboard.cpp.o
[ 17%] Building CXX object CMakeFiles/slopy.dir/src/x.cpp.o
[ 23%] Building CXX object CMakeFiles/slopy.dir/src/slopstates.cpp.o
[ 29%] Building CXX object CMakeFiles/slopy.dir/src/framebuffer.cpp.o
[ 35%] Building CXX object CMakeFiles/slopy.dir/src/resource.cpp.o
[ 41%] Building C object CMakeFiles/slopy.dir/src/gl_core_3_3.c.o
[ 47%] Building CXX object CMakeFiles/slopy.dir/src/shader.cpp.o
[ 52%] Building CXX object CMakeFiles/slopy.dir/src/window.cpp.o
[ 58%] Building CXX object CMakeFiles/slopy.dir/src/slop.cpp.o
[ 64%] Building CXX object CMakeFiles/slopy.dir/src/rectangle.cpp.o
[ 70%] Building CXX object CMakeFiles/slopy.dir/src/xshaperectangle.cpp.o
[ 76%] Building CXX object CMakeFiles/slopy.dir/src/glrectangle.cpp.o
[ 82%] Linking CXX shared library libslopy.so
[ 82%] Built target slopy
Scanning dependencies of target slop
[ 88%] Building CXX object CMakeFiles/slop.dir/src/options.cpp.o
[ 94%] Building CXX object CMakeFiles/slop.dir/src/main.cpp.o
[100%] Linking CXX executable ../bin/slop
[100%] Built target slop
Failed to detect a compositor, OpenGL hardware-accelleration disabled...
907x818+1644+1722
naelstrof commented 7 years ago

Ok so yup, #80 wasn't fixed.

I barely know what's going on, but I know how to replicate the issue (disabling unicode in slop and running really old nvidia drivers replicates this issue for me). This is a really strange issue where even if main.cpp contains

#include "cxxopts.hpp"
int main( int argc, char** argv ) {
    return 0;
}

It'll still segfault. It probably has something to do with how I link the libraries together or something. I'll have to sit around tweaking stuff until it works.

Any help would be appreciated.

naelstrof commented 7 years ago

Should actually be fixed now. So should #80.

For those of you who have an out-of-date slop and see this thread. The solution (provided you don't have access to the new patch) is that you can run LD_PRELOAD=/usr/lib/libpthread.so.1 slop which fixes the segfault during the preload.