Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1ee9ccb
Initial commit for epoll
userz Apr 4, 2025
18381f4
Simple test case
libumem Apr 4, 2025
1f12da5
Add del ql
libumem Apr 4, 2025
e208a34
Skeleton for graph
libumem Apr 4, 2025
2479b91
Flesh out tests, clean up
libumem Apr 7, 2025
f79d179
Merge branch 'qilingframework:dev' into dev
libumem Apr 22, 2025
290f116
Begin fixing this PR
libumem Apr 25, 2025
c6eee99
Add socket import back, was not supposed to be removed
libumem Apr 25, 2025
033fb4b
Address PR comments
libumem Apr 26, 2025
fd32154
Begin working on test issues
libumem Apr 26, 2025
f2861b7
Nominally working epoll server test
libumem Apr 26, 2025
f99e07a
Type annotations for args
libumem Apr 26, 2025
0022b8d
Refactor and fixes
elicn Apr 28, 2025
549673b
Merge pull request #1 from elicn/libumem-epoll-fixes
libumem Apr 28, 2025
74380b2
Address a few elicn comments, fix root for server test
libumem Apr 30, 2025
dbf2138
Turn check_epoll_depth into a prefix visitor
elicn Apr 30, 2025
96674e1
Use container semantics instead of is_present
elicn Apr 30, 2025
f108127
Fix events pointer handling
elicn Apr 30, 2025
0c96871
Fix returned events array
elicn Apr 30, 2025
bf83e9c
Cleanup and minor cosmetics
elicn Apr 30, 2025
5a87323
Tidy up tests
elicn Apr 30, 2025
12d3c58
Address last of feedback
libumem May 7, 2025
90df05f
Merge branch 'qilingframework:dev' into dev
libumem May 7, 2025
265406e
Merge branch 'dev' into libumem-epoll-fixes
libumem May 7, 2025
b724f4c
Merge pull request #2 from elicn/libumem-epoll-fixes
libumem May 7, 2025
e4242ca
Fix mem read issue
libumem May 8, 2025
f9497bc
Address more feedback
libumem May 9, 2025
47c3df1
Fix root for test case
libumem May 16, 2025
4d0b939
Revert "Fix root for test case"
libumem Jun 2, 2025
34fcfb5
Revert "Address more feedback"
libumem Jun 2, 2025
82de6f9
Revert "Fix mem read issue"
libumem Jun 2, 2025
5ad49c0
Revert "Revert "Fix root for test case""
libumem Jun 2, 2025
ca0d35a
Introduce packed struct
elicn Jun 3, 2025
31720cf
Refactor epoll to rely on ctypess tructure
elicn Jun 3, 2025
e0d8889
Merge pull request #3 from elicn/libumem-epoll-fixes
libumem Jun 3, 2025
92e43a3
Fix glibc issue with new test root
libumem Jun 4, 2025
fdfec5b
Attempt #1 to fix test case root
libumem Jun 17, 2025
d5b51dd
Remove dup'd comment, locally tested fix for error during ELFTest suite
libumem Jun 22, 2025
aefef5f
Disable test case, for now
libumem Jun 23, 2025
2ecd1d9
Merge branch 'qilingframework:dev' into dev
libumem Nov 13, 2025
a76b858
Tentative fix for epoll server test case
libumem Nov 14, 2025
4448d4c
Remove stray PDB invocation
libumem Nov 15, 2025
3675f55
Address @elicn feedback
libumem Nov 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qiling/os/posix/syscall/epoll.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def ql_syscall_epoll_ctl(ql: Qiling, epfd: int, op: int, fd: int, event: int):
if op not in (EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD):
return -EINVAL

if epfd == fd:
if epfd == fd or fd == 0xffffffff: # latter condition was seen in testing, but should not happen in the real world
return -EINVAL

if epfd not in range(NR_OPEN):
Expand Down
9 changes: 3 additions & 6 deletions tests/test_elf.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ def test_elf_linux_x8664_static(self):
ql = Qiling(["../examples/rootfs/x8664_linux/bin/x8664_hello_static"], "../examples/rootfs/x8664_linux", verbose=QL_VERBOSE.DEBUG)
ql.run()
del ql

#@unittest.skip('Experiment to avoid FD issue')
def test_elf_linux_x86(self):
filename = 'test.qlog'

ql = Qiling(["../examples/rootfs/x86_linux/bin/x86_hello"], "../examples/rootfs/x86_linux", verbose=QL_VERBOSE.DEBUG, log_devices=[filename])
ql.run()

ql._log_file_fd.handlers[0].close() # prevent FD leak that causes downstream issues
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very unusual.
Care to explain what this is about?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running this test case, there was a dangling FD pointing to ql.log on the disk after os.remove got invoked. This FD ended up being added to the epoll args, and not the legitimate server socket as I observed outside the test suite.

So here, I just force a closure to keep the FD list in a consistent state.

os.remove(filename)
del ql

Expand Down Expand Up @@ -789,8 +789,7 @@ def test_elf_linux_x8664_epoll_simple(self):
ql.run()

self.assertIn(b'echo\n', ql.os.stdout.read())
del ql
@unittest.skip("See comment in https://github.com/qilingframework/qiling/pull/1558")
del ql
def test_elf_linux_x8664_epoll_server(self):
# This tests a simple server that uses epoll to wait for data, then prints it out. It has
# been modified to exit after data has been received; instead of a typical server operation
Expand All @@ -810,7 +809,6 @@ def hook_newfstatat(ql: Qiling, dirfd: int, pathname: int, statbuf: int, flags:
def client():
# give time for the server to listen
time.sleep(3)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("127.0.0.1", 8000))
s.send(b"hello world")
Expand All @@ -826,7 +824,6 @@ def client():

client_thread = threading.Thread(target=client, daemon=True)
client_thread.start()

ql.run()

self.assertIn(b'hello world', ql.os.stdout.read(200)) # 200 is arbitrary--"good enough" for this task
Expand Down