Luming Wang has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/53143 )

Change subject: sim-se: add checks in selectFunc to fix up craches
......................................................................

sim-se: add checks in selectFunc to fix up craches

In selectFunc, FD_ZERO are invoked without checking whether
reinterpret_cast<fd_set *>((typename OS::fd_set *)readfds) is NULL.
So does writefds and errorfds.

Change-Id: I175fe1369c85fd8a832a227c3f90f25d772f33e1
---
M src/sim/syscall_emul.hh
1 file changed, 22 insertions(+), 3 deletions(-)



diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 6cbbf00..d78f4ac 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -2543,9 +2543,15 @@
     if (retval == -1)
         return -errno;

-    FD_ZERO(reinterpret_cast<fd_set *>((typename OS::fd_set *)readfds));
-    FD_ZERO(reinterpret_cast<fd_set *>((typename OS::fd_set *)writefds));
-    FD_ZERO(reinterpret_cast<fd_set *>((typename OS::fd_set *)errorfds));
+    if (readfds) {
+ FD_ZERO(reinterpret_cast<fd_set *>((typename OS::fd_set *)readfds));
+    }
+    if (writefds) {
+ FD_ZERO(reinterpret_cast<fd_set *>((typename OS::fd_set *)writefds));
+    }
+    if (errorfds) {
+ FD_ZERO(reinterpret_cast<fd_set *>((typename OS::fd_set *)errorfds));
+    }

     /**
      * We need to translate the host file descriptor set into a target file

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/53143
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I175fe1369c85fd8a832a227c3f90f25d772f33e1
Gerrit-Change-Number: 53143
Gerrit-PatchSet: 1
Gerrit-Owner: Luming Wang <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to