Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

umockdev-record does not record anything if recorded program overrides SIGINT #96

Closed
msergenergen opened this issue Sep 20, 2019 · 12 comments

Comments

@msergenergen
Copy link

msergenergen commented Sep 20, 2019

I want to mock touchpad. But I didn't record anything into ioctl file.
When I was checking to mouse.ioctl file, I saw only this part

@dev /dev/input/event5

Probably, I didn't record anything. But I didn't get any error messages after following step;
sudo umockdev-record -i /dev/input/event5=mouse.ioctl -e /dev/input/event5=mouse.events -- evtest /dev/input/event5

But I got this error message after following step;
umockdev-run -d mouse.umockdev -i /dev/input/event5=mouse.ioctl -e /dev/input/event5=mouse.events -- evtest /dev/input/event5

ERROR: libumockdev-preload: failed to load ioctl record file for /dev/input/event5: empty or invalid format

Do you want to recommend anything else?

@msergenergen
Copy link
Author

I tried running on another pc and devices (keyboard, external mouse, touchpad) (umockdev installation). But I didn't get any result.

@msergenergen
Copy link
Author

Also I tried install and run steps on another Ubuntu versions. (16,04 and 18,04) I got same error.

@DanielMalangu
Copy link

Yes, I have this exact issue. I'm not sure why no one has attempted to provide a solution. Is this a problem that is not common at all?

@msergenergen
Copy link
Author

Probably many people did not occur this problem.

@hadess
Copy link
Contributor

hadess commented Nov 3, 2020

You're missing one half of the commands, you also need to create the .umockdev file:
https://github.com/martinpitt/umockdev/blob/master/README.rst#record-and-replay-input-devices

(even though that doesn't work for me either)

@hadess
Copy link
Contributor

hadess commented Nov 4, 2020

Nothing is getting saved to disk:

$ sudo umockdev-record /dev/input/event18 > lap-proximity-switch.umockdev
$ sudo UMOCKDEV_DEBUG=all umockdev-record -i /dev/input/event18=lap-proximity-switch.ioctl -e /dev/input/event18=lap-proximity-switch.events -- evtest /dev/input/event18 
testbed wrapped open(/dev/input/event18) -> /dev/input/event18
ioctl_record_open: Starting new record lap-proximity-switch.ioctl
ioctl_record_open: starting ioctl recording of fd 3 into lap-proximity-switch.ioctl
init_script_dev_logfile_map: will record script of device 13:82 into lap-proximity-switch.events
script_record_open: start recording fd 3 on device 13:82 into lap-proximity-switch.events (format 1)
script_start_record: Starting new record of format 1
isatty(1): is a terminal, ttyname /dev/pts/2
isatty(1): readlink((null)/dev/.ptymap/_dev_pts_2) failed: No such file or directory
ioctl fd 3 request 80044501: original, result 0
ioctl_simplestruct_init_from_bin: EVIOCGVERSION(80044501): size is 4 bytes
Input driver version is 1.0.1
ioctl fd 3 request 80084502: original, result 0
ioctl_simplestruct_init_from_bin: EVIOCGID(80084502): size is 8 bytes
Input device ID: bus 0x6 vendor 0x0 product 0x0 version 0x0
ioctl fd 3 request 81004506: original, result 28
ioctl_simplestruct_init_from_bin: EVIOCGNAME(81004506): size is 256 bytes
Input device name: "Thinkpad proximity switches"
ioctl fd 3 request 801F4520: original, result 8
ioctl_simplestruct_init_from_bin: EVIOCGBIT(801F4520): size is 31 bytes
Supported events:
  Event type 0 (EV_SYN)
ioctl fd 3 request 9800451B: original, result 8
ioctl_simplestruct_init_from_bin: EVIOCGSW(9800451B): size is 6144 bytes
  Event type 5 (EV_SW)
ioctl fd 3 request 82FF4525: original, result 8
ioctl_simplestruct_init_from_bin: EVIOCGBIT(82FF4525): size is 767 bytes
    Event code 17 (?) state 0
ioctl fd 3 request 80F84509: original, result 8
ioctl_simplestruct_init_from_bin: EVIOCGPROP(80F84509): size is 248 bytes
Properties:
Testing ... (interrupt to exit)
ioctl fd 3 request 40044590: original, result 0
ioctl fd 3 request 40044590: original, result 0
script_record_op r: got 48 bytes on fd 3 (format 1)
Event: time 1604491485.311818, type 5 (EV_SW), code 17 (?), value 1
Event: time 1604491485.311818, -------------- SYN_REPORT ------------
script_record_op r: got 48 bytes on fd 3 (format 1)
Event: time 1604491487.536091, type 5 (EV_SW), code 17 (?), value 0
Event: time 1604491487.536091, -------------- SYN_REPORT ------------
^Cioctl fd 3 request 40044590: original, result -1
$ cat *ioctl
@DEV /dev/input/event18

Looks like DBG(DBG_IOCTL, "ioctl_record_sigint_handler: got signal %i, flushing record\n", signum); is never getting triggered. I also tested running in a root shell, rather than under sudo, but the signal handler is not getting triggered.

@hadess
Copy link
Contributor

hadess commented Nov 4, 2020

The interrupt handler in evtest is however getting triggered. Removing the signal handlers in evtest fixes it.

It might be useful to find a way to install the signal handler in a more robust way in libumockdev-preload.c. Right now, the signal handler in the preload is put in place before the one in evtest, which overrides it:

$ sudo UMOCKDEV_DEBUG=all LD_LIBRARY_PATH=/home/hadess/Projects/gnome-install/lib/ umockdev-record -i /dev/input/event18=lap-proximity-switch.ioctl -e /dev/input/event18=lap-proximity-switch.events -- /home/hadess/.cache/scratch/jhbuild/build/evtest/evtest /dev/input/event18
<snip>
ioctl_record PUTTING SIGNAL HANDLER IN PLACE
<snip>
PUTTING EVTEST SIGNAL HANDLERS IN PLACE
^Cinterrupt_handler called
ioctl fd 3 request 40044590: original, result -1

@hadess
Copy link
Contributor

hadess commented Nov 4, 2020

@hadess hadess mentioned this issue Nov 4, 2020
@martinpitt
Copy link
Owner

I'm of course open to suggestions how else umockdev-record (i.e. the preload library) could be told to stop recording and start writing the file. SIGINT seemed like an obvious choice back then, but indeed signal handlers don't chain well. Another possibility is to add some timeout to evtest and just let that exit cleanly?

@martinpitt martinpitt changed the title I couldn't record to *.ioctl file anything umockdev-record does not record anything if recorded program overrides SIGINT Jan 24, 2021
benzea pushed a commit to benzea/umockdev that referenced this issue Mar 19, 2021
Note that this changes the ioctl_tree_insert API to be more vala
friendly. i.e. it will return the new tree pointer, and it will always
take the passed tree node, free'ing it if a duplicate has been found.

This fixes storing the record if the process overrides SIGINT for
ioctl's. See martinpitt#96
benzea pushed a commit to benzea/umockdev that referenced this issue Mar 31, 2021
Note that this changes the ioctl_tree_insert API to be more vala
friendly. i.e. it will return the new tree pointer, and it will always
take the passed tree node, free'ing it if a duplicate has been found.

This fixes storing the record if the process overrides SIGINT for
ioctl's. See martinpitt#96
@georgiablanco
Copy link

Hello. I am having the same problem. Has this issue been resolved? Or has anyone got a work around?

@martinpitt
Copy link
Owner

@georgiablanco : It has not been resolved, no. This will require some bigger reworking which didn't land yet.

(I tried to reply to your email, and your hotmail server rejected it 🤷 )

@ethanfowler
Copy link

Just to check my understanding of the situation, correct me if I'm wrong:

Because evtest registers its own SIGINT handler, umockdev-record doesn't close cleanly and write the recorded data to disk?

Does this mean that https://github.com/martinpitt/umockdev#record-and-replay-input-devices does not currently work?

Is there an evtest alternative or workaround at current?

benzea pushed a commit to benzea/umockdev that referenced this issue May 21, 2021
Note that this changes the ioctl_tree_insert API to be more vala
friendly. i.e. it will return the new tree pointer, and it will always
take the passed tree node, free'ing it if a duplicate has been found.

This fixes storing the record if the process overrides SIGINT for
ioctl's. See martinpitt#96
benzea pushed a commit to benzea/umockdev that referenced this issue May 26, 2021
Note that this changes the ioctl_tree_insert API to be more vala
friendly. i.e. it will return the new tree pointer, and it will always
take the passed tree node, free'ing it if a duplicate has been found.

This fixes storing the record if the process overrides SIGINT for
ioctl's. See martinpitt#96
benzea pushed a commit to benzea/umockdev that referenced this issue May 31, 2021
Note that this changes the ioctl_tree_insert API to be more vala
friendly. i.e. it will return the new tree pointer, and it will always
take the passed tree node, free'ing it if a duplicate has been found.

This fixes storing the record if the process overrides SIGINT for
ioctl's. See martinpitt#96
martinpitt pushed a commit to benzea/umockdev that referenced this issue Jun 1, 2021
Note that this changes the ioctl_tree_insert API to be more vala
friendly. i.e. it will return the new tree pointer, and it will always
take the passed tree node, free'ing it if a duplicate has been found.

This fixes storing the record if the process overrides SIGINT for
ioctl's.

Fixes martinpitt#96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants