From: Rhys Kidd Date: Sat, 7 Mar 2015 08:36:20 +0000 (+0000) Subject: Fix unhandled syscall: unix:348 (__pthread_chdir) and unhandled syscall: unix:349... X-Git-Tag: svn/VALGRIND_3_11_0~605 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6edce5f4a459f119ab0d4e7b1ee50d052a8a113;p=thirdparty%2Fvalgrind.git Fix unhandled syscall: unix:348 (__pthread_chdir) and unhandled syscall: unix:349 (__pthread_fchdir) on OS X bz#344512 - Support these two undocumented syscalls. - New regression test case added. Before: == 588 tests, 239 stderr failures, 22 stdout failures, 0 stderrB failures, 0 stdoutB failures, 31 post failures == After: == 589 tests, 239 stderr failures, 22 stdout failures, 0 stderrB failures, 0 stdoutB failures, 31 post failures == git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14987 --- diff --git a/NEWS b/NEWS index b7d2680e18..dbef0d4dec 100644 --- a/NEWS +++ b/NEWS @@ -115,6 +115,8 @@ where XXXXXX is the bug number as listed below. 344499 Fix compilation for Linux kernel >= 4. With this, also require a Linux kernel >= 2.6 as 2.4 is mostly untested and might trigger obvious and non-obvious issues +344512 Fix unhandled syscall: unix:348 (__pthread_chdir) and unhandled + syscall: unix:349 (__pthread_fchdir) on OS X 344560 Fix stack traces missing penultimate frame on OS X 344621 Fix memcheck/tests/err_disable4 test on OS X 344686 Fix suppression for pthread_rwlock_init on OS X 10.10 diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h index 9351b81b75..1360719fd4 100644 --- a/coregrind/m_syswrap/priv_syswrap-darwin.h +++ b/coregrind/m_syswrap/priv_syswrap-darwin.h @@ -416,8 +416,8 @@ DECL_TEMPLATE(darwin, getdirentries64); // 344 DECL_TEMPLATE(darwin, statfs64); // 345 DECL_TEMPLATE(darwin, fstatfs64); // 346 DECL_TEMPLATE(darwin, getfsstat64); // 347 -// NYI __pthread_chdir 348 -// NYI __pthread_fchdir 349 +DECL_TEMPLATE(darwin, __pthread_chdir); // 348 +DECL_TEMPLATE(darwin, __pthread_fchdir); // 349 // NYI audit 350 DECL_TEMPLATE(darwin, auditon); // 351 // 352 diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index cd4043aa5f..84e2ba1d3f 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -2186,6 +2186,22 @@ PRE(__disable_threadsignal) } +PRE(__pthread_chdir) +{ + PRINT("__pthread_chdir ( %#lx(%s) )", ARG1, (char*)ARG1); + PRE_REG_READ1(long, "__pthread_chdir", const char *, path); + PRE_MEM_RASCIIZ( "__pthread_chdir(path)", ARG1 ); +} + + + +PRE(__pthread_fchdir) +{ + PRINT("__pthread_fchdir ( %ld )", ARG1); + PRE_REG_READ1(long, "__pthread_fchdir", unsigned int, fd); +} + + PRE(kdebug_trace) { PRINT("kdebug_trace(%ld, %ld, %ld, %ld, %ld, %ld)", @@ -9671,8 +9687,8 @@ const SyscallTableEntry ML_(syscall_table)[] = { MACXY(__NR_statfs64, statfs64), MACXY(__NR_fstatfs64, fstatfs64), MACXY(__NR_getfsstat64, getfsstat64), -// _____(__NR___pthread_chdir), -// _____(__NR___pthread_fchdir), + MACX_(__NR___pthread_chdir, __pthread_chdir), + MACX_(__NR___pthread_fchdir, __pthread_fchdir), // _____(__NR_audit), MACXY(__NR_auditon, auditon), _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(352)), // ??? diff --git a/memcheck/tests/darwin/Makefile.am b/memcheck/tests/darwin/Makefile.am index b3d2508ac9..f5deb34a51 100644 --- a/memcheck/tests/darwin/Makefile.am +++ b/memcheck/tests/darwin/Makefile.am @@ -10,6 +10,7 @@ EXTRA_DIST = \ deep_badparam.stderr.exp deep_badparam.stdout.exp deep_badparam.vgtest \ env.stderr.exp env.vgtest \ pth-supp.stderr.exp pth-supp.vgtest \ + pth-undocumented.stderr.exp pth-undocumented.stdout.exp pth-undocumented.vgtest \ scalar.stderr.exp scalar.vgtest \ scalar_fork.stderr.exp scalar_fork.vgtest \ scalar_nocancel.stderr.exp scalar_nocancel.vgtest \ @@ -20,6 +21,7 @@ check_PROGRAMS = \ deep_badparam \ env \ pth-supp \ + pth-undocumented \ scalar \ scalar_fork \ scalar_nocancel \ diff --git a/memcheck/tests/darwin/pth-undocumented.c b/memcheck/tests/darwin/pth-undocumented.c new file mode 100644 index 0000000000..d9a5192b2b --- /dev/null +++ b/memcheck/tests/darwin/pth-undocumented.c @@ -0,0 +1,41 @@ +#include +#include + +#include +#include +#include + +#ifndef SYS___pthread_chdir +# define SYS___pthread_chdir 348 +#endif + +#ifndef SYS___pthread_fchdir +# define SYS___pthread_fchdir 349 +#endif + +int __pthread_chdir(const char *path) +{ + return syscall(SYS___pthread_chdir, path); +} + +int __pthread_fchdir(int dirfd) +{ + return syscall(SYS___pthread_fchdir, dirfd); +} + +int main(void) +{ + int dirfd; + + dirfd = open("/", O_RDONLY); + if (dirfd == -1) + perror("open"), exit(1); + + if (__pthread_chdir("/")) + perror("__pthread_chdir"); + + if (__pthread_fchdir(dirfd)) + perror("__pthread_fchdir"); + + return 0; +} diff --git a/memcheck/tests/darwin/pth-undocumented.stderr.exp b/memcheck/tests/darwin/pth-undocumented.stderr.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/memcheck/tests/darwin/pth-undocumented.stdout.exp b/memcheck/tests/darwin/pth-undocumented.stdout.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/memcheck/tests/darwin/pth-undocumented.vgtest b/memcheck/tests/darwin/pth-undocumented.vgtest new file mode 100644 index 0000000000..58d09df304 --- /dev/null +++ b/memcheck/tests/darwin/pth-undocumented.vgtest @@ -0,0 +1,2 @@ +prog: pth-undocumented +vgopts: -q