Giter Club home page Giter Club logo

Comments (11)

sodface avatar sodface commented on September 21, 2024 1

The /etc/abuild.conf has:

export CFLAGS="-Os -fomit-frame-pointer"
export CXXFLAGS="$CFLAGS"
export CPPFLAGS="$CFLAGS"
export LDFLAGS="-Wl,--as-needed,-O1,--sort-common"
export GOFLAGS="-buildmode=pie"

Does it segfault with the sample-reader in non-debug mode.

Will test.

Also you are using musl and gcc right?

Correct.

from libsgestures.

TAAPArthur avatar TAAPArthur commented on September 21, 2024

Interesting.

Double checked and realized that I haven't push to this repo in a while so synced my latest version. Testing with that and I can't repoduce your issue, although not sure what the cause is.

If you can reproduce it reliably, could you try running make debug and then doing a 3-finger tap. The debug target will just load up the sample which will just print all events it received.

from libsgestures.

sodface avatar sodface commented on September 21, 2024

Thanks, a couple observations:

  • I had to remove -Werror from the Makefile to get debug to build (using Alpine's build system)
  • Three finger tap does not seg fault using the debug binaries
  • With the latest commit non-debug build, the GestureEndMask doesn't print EAST, WEST etc. though it does print TAP, debug build prints all masks, eg:

non-debug:

GestureEndMask
GestureEndMask
GestureEndMask TAP
GestureEndMask
GestureEndMask

debug:

GestureEndMask WEST
GestureEndMask EAST
GestureEndMask TAP
GestureEndMask WEST

I need to step back to the previous commit I guess just to confirm it's there and not something with the config.c file I'm using to build the sgestures reader.

Non-debug build from the latest commit is still seg faulting on 3 finger tap though. Seems like the biggest difference is the sample reader vs the config.c version.

from libsgestures.

TAAPArthur avatar TAAPArthur commented on September 21, 2024

I had to remove -Werror from the Makefile to get debug to build (using Alpine's build system)

What CFLAGS/CPPFlags are the default for Alpine? echo "CFLAGS='$CFLAGS'" "CPPFLAGS='$CPPFLAGS'" should tell you. If not can you share the output of make after a make clean

Non-debug build from the latest commit is still seg faulting on 3 finger tap though. Seems like the biggest difference is the sample reader vs the config.c version.

Does it segfault with the sample-reader in non-debug mode. Just want to remove the possibility that it is some issue with the config.

Also does make test pass. You made need this header.

Also you are using musl and gcc right? Tried building with gcc and I think I see some of your -Werror related errors. Will rebuild with gcc and see if I can repro the segfault later today.

from libsgestures.

sodface avatar sodface commented on September 21, 2024

I should point out this is on armv7 with Alpine 3.16.1 and a custom kernel 5.15.55. On a 3 finger tap, strace is showing a bunch of mmap2 and munmap output before it seg faults. Below is a one finger tap, followed by a two finger tap, followed by a three finger tap that seg faults.

execve("/srv/packages/local/armv7/sample-gesture-reader", ["/srv/packages/local/armv7/sample"...], 0xbeb9ed40 /* 19 vars */) = 0
set_tls(0xaa6d4400)                     = 0
set_tid_address(0xaa6d37cc)             = 7556
brk(NULL)                               = 0xeef9000
brk(0xeefb000)                          = 0xeefb000
mmap2(0xeef9000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xeef9000
mprotect(0xda82000, 4096, PROT_READ)    = 0
rt_sigaction(SIGCHLD, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0xaa68a143}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
read(0, "\4\0\0\0\0\0\0\0\0\0\0\0\351\0\0\0`\0\0\0L\0\0\0007\0\0\0\310\n\251\7"..., 36) = 36
read(0, "\0", 1)                        = 1
read(0, "\20\0\0\0\0\0\0\0\0\0\0\0\351\0\0\0`\0\0\0L\0\0\08\0\0\0\370\n\251\7"..., 36) = 36
read(0, "\20\0\0\0\0\0\0\0\0\0\0\0\351\0\0\0a\0\0\0L\0\0\08\0\0\0\0\v\251\7"..., 36) = 36
read(0, "\20\0\0\0\0\0\0\0\0\0\0\0\351\0\0\0a\0\0\0L\0\0\08\0\0\0\10\v\251\7"..., 36) = 36
read(0, "\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\30\v\251\7"..., 36) = 36
ioctl(1, TIOCGWINSZ, {ws_row=33, ws_col=125, ws_xpixel=0, ws_ypixel=0}) = 0
writev(1, [{iov_base="GestureEndMask TAP", iov_len=18}, {iov_base="\n", iov_len=1}], 2) = 19
read(0, "\4\0\0\0\0\0\0\0\0\0\0\0\346\0\0\0R\0\0\0K\0\0\0/\0\0\0\347\17\251\7"..., 36) = 36
read(0, "\0", 1)                        = 1
read(0, "\4\0\0\0\0\0\0\0\1\0\0\0\311\0\0\0W\0\0\0A\0\0\0002\0\0\0\360\17\251\7"..., 36) = 36
read(0, "\0", 1)                        = 1
read(0, "\20\0\0\0\0\0\0\0\0\0\0\0\346\0\0\0Q\0\0\0K\0\0\0/\0\0\0H\20\251\7"..., 36) = 36
read(0, "\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0X\20\251\7"..., 36) = 36
read(0, "\2\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0`\20\251\7"..., 36) = 36
writev(1, [{iov_base="GestureEndMask TAP", iov_len=18}, {iov_base="\n", iov_len=1}], 2) = 19
read(0, "\4\0\0\0\0\0\0\0\0\0\0\0\344\0\0\0H\0\0\0J\0\0\0)\0\0\0\266\26\251\7"..., 36) = 36
read(0, "\0", 1)                        = 1
read(0, "\4\0\0\0\0\0\0\0\1\0\0\0\253\0\0\0X\0\0\08\0\0\0003\0\0\0\266\26\251\7"..., 36) = 36
read(0, "\0", 1)                        = 1
read(0, "\4\0\0\0\0\0\0\0\2\0\0\0\304\0\0\0K\0\0\0@\0\0\0+\0\0\0\306\26\251\7"..., 36) = 36
read(0, "\0", 1)                        = 1
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xaa6d1000
munmap(0xaa6d1000, 4096)                = 0
read(0, "\20\0\0\0\0\0\0\0\1\0\0\0\253\0\0\0X\0\0\08\0\0\0003\0\0\0\346\26\251\7"..., 36) = 36
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xaa6d1000
munmap(0xaa6d1000, 4096)                = 0
read(0, "\2\0\0\0\0\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0G\27\251\7"..., 36) = 36
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xaa6d1000
munmap(0xaa6d1000, 4096)                = 0
read(0, "\2\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0W\27\251\7"..., 36) = 36
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xaa6d1000
munmap(0xaa6d1000, 4096)                = 0
read(0, "\20\0\0\0\0\0\0\0\0\0\0\0\344\0\0\0H\0\0\0J\0\0\0)\0\0\0^\27\251\7"..., 36) = 36
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xaa6d1000
munmap(0xaa6d1000, 4096)                = 0
read(0, "\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0f\27\251\7"..., 36) = 36
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xaa6d1000
munmap(0xaa6d1000, 4096)                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xaa6d1000
writev(1, [{iov_base="GestureEndMask TAP", iov_len=18}, {iov_base="\n", iov_len=1}], 2) = 19
munmap(0xaa6d1000, 4096)                = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0xaa6d1254} ---
+++ killed by SIGSEGV +++

from libsgestures.

TAAPArthur avatar TAAPArthur commented on September 21, 2024

I had to remove -Werror from the Makefile to get debug to build (using Alpine's build system)

You should be able to build now. This was more of a difference in warning between tcc and gcc than being related to Alpine.

Three finger tap does not seg fault using the debug binaries
With the latest commit non-debug build, the GestureEndMask doesn't print EAST, WEST etc. though it does print TAP, debug build prints all masks, eg:

I haven't been able to repo either of these but don't have an armv7 device on hand. Still looking. There is one small gotcha I probably should point out; becarful calling sgestures without recompiling after a reinstall. It won't be updated unless you explictly recompile or delete the binary in ~/.local/share/sgestures/sgestures

Other than that, do you have a stacktrace/fault address? With gcc, running under gdb would easily provide it when compiling with -g.

from libsgestures.

sodface avatar sodface commented on September 21, 2024

I haven't used gdb much, does this help at all? Note that sample-gesture-reader is not the same as the one distributed with the source, I just copied my config.c in it's place and did a make debug.

Reading symbols from /srv/packages/local/armv7/sample-gesture-reader...
(gdb) run < <(sgestures-libinput-writer)
Starting program: /srv/packages/local/armv7/sample-gesture-reader < <(sgestures-libinput-writer)
GestureEndMask: Fingers 1 duration 80ms TAP
GestureEndMask: Fingers 2 duration 112ms TAP
GestureEndMask: Fingers 3 duration 160ms TAP

Program received signal SIGSEGV, Segmentation fault.
enqueueEvent (event=0xb6ff9030) at gesture-event.c:61
61	gesture-event.c: No such file or directory.
(gdb) 

from libsgestures.

TAAPArthur avatar TAAPArthur commented on September 21, 2024

Yes that does. Running bt at that prompt would be a tad more helpful. It should give the full call stack so I'll know how we ended up at line 61 in gesture-event.c with an invalid event.

 57 void enqueueEvent(GestureEvent* event) {
 58     assert(event);
 59     if(event->flags.mask & gestureSelectMask) {
 60         gestureEventHandler(event);
 61         if(event->flags.reflectionMask) {
 62             GestureEvent* reflectionEvent = malloc(sizeof(GestureEvent));
 63             memcpy(reflectionEvent, event, sizeof(GestureEvent));
 64             if(reflectionEvent->flags.reflectionMask == Rotate90Mask)
 65                 reflectionEvent->flags.reflectionMask = Rotate270Mask;
 66             else if(reflectionEvent->flags.reflectionMask == Rotate270Mask)
 67                 reflectionEvent->flags.reflectionMask = Rotate90Mask;
 68             transformGestureDetail(reflectionEvent->detail, reflectionEvent->flags.reflectionMask);
 69             gestureEventHandler(reflectionEvent);
 70         }
 71     }
 72     else {
 73         free(event);
 74     }
 75 }

So this is the problematic method. I find it strange that the crashed happened right after the event was dumped...

Oh I do see a potential problem, if you move line 60 right after the end block/right before line 70, does the problem go away. If the dumpAndFreeGesture method was used I could easily see a segfault. It shouldn't be used by default, so this might be another bug. It is at least a real problem with my config.c

from libsgestures.

sodface avatar sodface commented on September 21, 2024

move line 60 right after the end block/right before line 70, does the problem go away.

Yes! Working good now!!

Just to be sure I made the correct edit:

--- src/libsgestures-d76e9b0ad3dbb2a92c7eebe90c1bd3191a9859b3/gesture-event.c
+++ gesture-event.c
@@ -57,7 +57,6 @@
 void enqueueEvent(GestureEvent* event) {
     assert(event);
     if(event->flags.mask & gestureSelectMask) {
-        gestureEventHandler(event);
         if(event->flags.reflectionMask) {
             GestureEvent* reflectionEvent = malloc(sizeof(GestureEvent));
             memcpy(reflectionEvent, event, sizeof(GestureEvent));
@@ -68,6 +67,7 @@
             transformGestureDetail(reflectionEvent->detail, reflectionEvent->flags.reflectionMask);
             gestureEventHandler(reflectionEvent);
         }
+        gestureEventHandler(event);
     }
     else {
         free(event);

from libsgestures.

TAAPArthur avatar TAAPArthur commented on September 21, 2024

Geat. I'll push a proper fix then. Thank for catching another bug

from libsgestures.

TAAPArthur avatar TAAPArthur commented on September 21, 2024

9d8efad should fix this issue.

from libsgestures.

Related Issues (4)

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.