The Samba-Bugzilla – Attachment 11412 Details for
Bug 11413
Crash when using multiple contexts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Includes Metze's patch.
threads-fixes (text/plain), 15.96 KB, created by
Jeremy Allison
on 2015-09-04 21:04:43 UTC
(
hide
)
Description:
Includes Metze's patch.
Filename:
MIME Type:
Creator:
Jeremy Allison
Created:
2015-09-04 21:04:43 UTC
Size:
15.96 KB
patch
obsolete
>From 75a61f4c59b634a5c69da2ac6408e436e6c9b833 Mon Sep 17 00:00:00 2001 >From: Stefan Metzmacher <metze@samba.org> >Date: Mon, 3 Aug 2015 09:43:33 +0200 >Subject: [PATCH 1/3] s3:libsmb: compile libsmb_thread_impl.c and > libsmb_thread_posix.c > >We need to provide smbc_thread_impl() and smbc_thread_posix() to >external callers. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=11413 > >Signed-off-by: Stefan Metzmacher <metze@samba.org> >--- > source3/libsmb/ABI/smbclient-0.2.4.sigs | 181 ++++++++++++++++++++++++++++++++ > source3/libsmb/wscript | 13 ++- > 2 files changed, 191 insertions(+), 3 deletions(-) > create mode 100644 source3/libsmb/ABI/smbclient-0.2.4.sigs > >diff --git a/source3/libsmb/ABI/smbclient-0.2.4.sigs b/source3/libsmb/ABI/smbclient-0.2.4.sigs >new file mode 100644 >index 0000000..ee1ba01 >--- /dev/null >+++ b/source3/libsmb/ABI/smbclient-0.2.4.sigs >@@ -0,0 +1,181 @@ >+smbc_chmod: int (const char *, mode_t) >+smbc_close: int (int) >+smbc_closedir: int (int) >+smbc_creat: int (const char *, mode_t) >+smbc_fgetxattr: int (int, const char *, const void *, size_t) >+smbc_flistxattr: int (int, char *, size_t) >+smbc_free_context: int (SMBCCTX *, int) >+smbc_fremovexattr: int (int, const char *) >+smbc_fsetxattr: int (int, const char *, const void *, size_t, int) >+smbc_fstat: int (int, struct stat *) >+smbc_fstatvfs: int (int, struct statvfs *) >+smbc_ftruncate: int (int, off_t) >+smbc_getDebug: int (SMBCCTX *) >+smbc_getFunctionAddCachedServer: smbc_add_cached_srv_fn (SMBCCTX *) >+smbc_getFunctionAuthData: smbc_get_auth_data_fn (SMBCCTX *) >+smbc_getFunctionAuthDataWithContext: smbc_get_auth_data_with_context_fn (SMBCCTX *) >+smbc_getFunctionCheckServer: smbc_check_server_fn (SMBCCTX *) >+smbc_getFunctionChmod: smbc_chmod_fn (SMBCCTX *) >+smbc_getFunctionClose: smbc_close_fn (SMBCCTX *) >+smbc_getFunctionClosedir: smbc_closedir_fn (SMBCCTX *) >+smbc_getFunctionCreat: smbc_creat_fn (SMBCCTX *) >+smbc_getFunctionFstat: smbc_fstat_fn (SMBCCTX *) >+smbc_getFunctionFstatVFS: smbc_fstatvfs_fn (SMBCCTX *) >+smbc_getFunctionFstatdir: smbc_fstatdir_fn (SMBCCTX *) >+smbc_getFunctionFtruncate: smbc_ftruncate_fn (SMBCCTX *) >+smbc_getFunctionGetCachedServer: smbc_get_cached_srv_fn (SMBCCTX *) >+smbc_getFunctionGetdents: smbc_getdents_fn (SMBCCTX *) >+smbc_getFunctionGetxattr: smbc_getxattr_fn (SMBCCTX *) >+smbc_getFunctionListPrintJobs: smbc_list_print_jobs_fn (SMBCCTX *) >+smbc_getFunctionListxattr: smbc_listxattr_fn (SMBCCTX *) >+smbc_getFunctionLseek: smbc_lseek_fn (SMBCCTX *) >+smbc_getFunctionLseekdir: smbc_lseekdir_fn (SMBCCTX *) >+smbc_getFunctionMkdir: smbc_mkdir_fn (SMBCCTX *) >+smbc_getFunctionNotify: smbc_notify_fn (SMBCCTX *) >+smbc_getFunctionOpen: smbc_open_fn (SMBCCTX *) >+smbc_getFunctionOpenPrintJob: smbc_open_print_job_fn (SMBCCTX *) >+smbc_getFunctionOpendir: smbc_opendir_fn (SMBCCTX *) >+smbc_getFunctionPrintFile: smbc_print_file_fn (SMBCCTX *) >+smbc_getFunctionPurgeCachedServers: smbc_purge_cached_fn (SMBCCTX *) >+smbc_getFunctionRead: smbc_read_fn (SMBCCTX *) >+smbc_getFunctionReaddir: smbc_readdir_fn (SMBCCTX *) >+smbc_getFunctionRemoveCachedServer: smbc_remove_cached_srv_fn (SMBCCTX *) >+smbc_getFunctionRemoveUnusedServer: smbc_remove_unused_server_fn (SMBCCTX *) >+smbc_getFunctionRemovexattr: smbc_removexattr_fn (SMBCCTX *) >+smbc_getFunctionRename: smbc_rename_fn (SMBCCTX *) >+smbc_getFunctionRmdir: smbc_rmdir_fn (SMBCCTX *) >+smbc_getFunctionSetxattr: smbc_setxattr_fn (SMBCCTX *) >+smbc_getFunctionSplice: smbc_splice_fn (SMBCCTX *) >+smbc_getFunctionStat: smbc_stat_fn (SMBCCTX *) >+smbc_getFunctionStatVFS: smbc_statvfs_fn (SMBCCTX *) >+smbc_getFunctionTelldir: smbc_telldir_fn (SMBCCTX *) >+smbc_getFunctionUnlink: smbc_unlink_fn (SMBCCTX *) >+smbc_getFunctionUnlinkPrintJob: smbc_unlink_print_job_fn (SMBCCTX *) >+smbc_getFunctionUtimes: smbc_utimes_fn (SMBCCTX *) >+smbc_getFunctionWrite: smbc_write_fn (SMBCCTX *) >+smbc_getNetbiosName: char *(SMBCCTX *) >+smbc_getOptionBrowseMaxLmbCount: int (SMBCCTX *) >+smbc_getOptionCaseSensitive: smbc_bool (SMBCCTX *) >+smbc_getOptionDebugToStderr: smbc_bool (SMBCCTX *) >+smbc_getOptionFallbackAfterKerberos: smbc_bool (SMBCCTX *) >+smbc_getOptionFullTimeNames: smbc_bool (SMBCCTX *) >+smbc_getOptionNoAutoAnonymousLogin: smbc_bool (SMBCCTX *) >+smbc_getOptionOneSharePerServer: smbc_bool (SMBCCTX *) >+smbc_getOptionOpenShareMode: smbc_share_mode (SMBCCTX *) >+smbc_getOptionSmbEncryptionLevel: smbc_smb_encrypt_level (SMBCCTX *) >+smbc_getOptionUrlEncodeReaddirEntries: smbc_bool (SMBCCTX *) >+smbc_getOptionUseCCache: smbc_bool (SMBCCTX *) >+smbc_getOptionUseKerberos: smbc_bool (SMBCCTX *) >+smbc_getOptionUseNTHash: smbc_bool (SMBCCTX *) >+smbc_getOptionUserData: void *(SMBCCTX *) >+smbc_getPort: uint16_t (SMBCCTX *) >+smbc_getServerCacheData: struct smbc_server_cache *(SMBCCTX *) >+smbc_getTimeout: int (SMBCCTX *) >+smbc_getUser: char *(SMBCCTX *) >+smbc_getWorkgroup: char *(SMBCCTX *) >+smbc_getdents: int (unsigned int, struct smbc_dirent *, int) >+smbc_getxattr: int (const char *, const char *, const void *, size_t) >+smbc_init: int (smbc_get_auth_data_fn, int) >+smbc_init_context: SMBCCTX *(SMBCCTX *) >+smbc_lgetxattr: int (const char *, const char *, const void *, size_t) >+smbc_list_print_jobs: int (const char *, smbc_list_print_job_fn) >+smbc_listxattr: int (const char *, char *, size_t) >+smbc_llistxattr: int (const char *, char *, size_t) >+smbc_lremovexattr: int (const char *, const char *) >+smbc_lseek: off_t (int, off_t, int) >+smbc_lseekdir: int (int, off_t) >+smbc_lsetxattr: int (const char *, const char *, const void *, size_t, int) >+smbc_mkdir: int (const char *, mode_t) >+smbc_new_context: SMBCCTX *(void) >+smbc_notify: int (int, smbc_bool, uint32_t, unsigned int, smbc_notify_callback_fn, void *) >+smbc_open: int (const char *, int, mode_t) >+smbc_open_print_job: int (const char *) >+smbc_opendir: int (const char *) >+smbc_option_get: void *(SMBCCTX *, char *) >+smbc_option_set: void (SMBCCTX *, char *, ...) >+smbc_print_file: int (const char *, const char *) >+smbc_read: ssize_t (int, void *, size_t) >+smbc_readdir: struct smbc_dirent *(unsigned int) >+smbc_removexattr: int (const char *, const char *) >+smbc_rename: int (const char *, const char *) >+smbc_rmdir: int (const char *) >+smbc_setDebug: void (SMBCCTX *, int) >+smbc_setFunctionAddCachedServer: void (SMBCCTX *, smbc_add_cached_srv_fn) >+smbc_setFunctionAuthData: void (SMBCCTX *, smbc_get_auth_data_fn) >+smbc_setFunctionAuthDataWithContext: void (SMBCCTX *, smbc_get_auth_data_with_context_fn) >+smbc_setFunctionCheckServer: void (SMBCCTX *, smbc_check_server_fn) >+smbc_setFunctionChmod: void (SMBCCTX *, smbc_chmod_fn) >+smbc_setFunctionClose: void (SMBCCTX *, smbc_close_fn) >+smbc_setFunctionClosedir: void (SMBCCTX *, smbc_closedir_fn) >+smbc_setFunctionCreat: void (SMBCCTX *, smbc_creat_fn) >+smbc_setFunctionFstat: void (SMBCCTX *, smbc_fstat_fn) >+smbc_setFunctionFstatVFS: void (SMBCCTX *, smbc_fstatvfs_fn) >+smbc_setFunctionFstatdir: void (SMBCCTX *, smbc_fstatdir_fn) >+smbc_setFunctionFtruncate: void (SMBCCTX *, smbc_ftruncate_fn) >+smbc_setFunctionGetCachedServer: void (SMBCCTX *, smbc_get_cached_srv_fn) >+smbc_setFunctionGetdents: void (SMBCCTX *, smbc_getdents_fn) >+smbc_setFunctionGetxattr: void (SMBCCTX *, smbc_getxattr_fn) >+smbc_setFunctionListPrintJobs: void (SMBCCTX *, smbc_list_print_jobs_fn) >+smbc_setFunctionListxattr: void (SMBCCTX *, smbc_listxattr_fn) >+smbc_setFunctionLseek: void (SMBCCTX *, smbc_lseek_fn) >+smbc_setFunctionLseekdir: void (SMBCCTX *, smbc_lseekdir_fn) >+smbc_setFunctionMkdir: void (SMBCCTX *, smbc_mkdir_fn) >+smbc_setFunctionNotify: void (SMBCCTX *, smbc_notify_fn) >+smbc_setFunctionOpen: void (SMBCCTX *, smbc_open_fn) >+smbc_setFunctionOpenPrintJob: void (SMBCCTX *, smbc_open_print_job_fn) >+smbc_setFunctionOpendir: void (SMBCCTX *, smbc_opendir_fn) >+smbc_setFunctionPrintFile: void (SMBCCTX *, smbc_print_file_fn) >+smbc_setFunctionPurgeCachedServers: void (SMBCCTX *, smbc_purge_cached_fn) >+smbc_setFunctionRead: void (SMBCCTX *, smbc_read_fn) >+smbc_setFunctionReaddir: void (SMBCCTX *, smbc_readdir_fn) >+smbc_setFunctionRemoveCachedServer: void (SMBCCTX *, smbc_remove_cached_srv_fn) >+smbc_setFunctionRemoveUnusedServer: void (SMBCCTX *, smbc_remove_unused_server_fn) >+smbc_setFunctionRemovexattr: void (SMBCCTX *, smbc_removexattr_fn) >+smbc_setFunctionRename: void (SMBCCTX *, smbc_rename_fn) >+smbc_setFunctionRmdir: void (SMBCCTX *, smbc_rmdir_fn) >+smbc_setFunctionSetxattr: void (SMBCCTX *, smbc_setxattr_fn) >+smbc_setFunctionSplice: void (SMBCCTX *, smbc_splice_fn) >+smbc_setFunctionStat: void (SMBCCTX *, smbc_stat_fn) >+smbc_setFunctionStatVFS: void (SMBCCTX *, smbc_statvfs_fn) >+smbc_setFunctionTelldir: void (SMBCCTX *, smbc_telldir_fn) >+smbc_setFunctionUnlink: void (SMBCCTX *, smbc_unlink_fn) >+smbc_setFunctionUnlinkPrintJob: void (SMBCCTX *, smbc_unlink_print_job_fn) >+smbc_setFunctionUtimes: void (SMBCCTX *, smbc_utimes_fn) >+smbc_setFunctionWrite: void (SMBCCTX *, smbc_write_fn) >+smbc_setNetbiosName: void (SMBCCTX *, char *) >+smbc_setOptionBrowseMaxLmbCount: void (SMBCCTX *, int) >+smbc_setOptionCaseSensitive: void (SMBCCTX *, smbc_bool) >+smbc_setOptionDebugToStderr: void (SMBCCTX *, smbc_bool) >+smbc_setOptionFallbackAfterKerberos: void (SMBCCTX *, smbc_bool) >+smbc_setOptionFullTimeNames: void (SMBCCTX *, smbc_bool) >+smbc_setOptionNoAutoAnonymousLogin: void (SMBCCTX *, smbc_bool) >+smbc_setOptionOneSharePerServer: void (SMBCCTX *, smbc_bool) >+smbc_setOptionOpenShareMode: void (SMBCCTX *, smbc_share_mode) >+smbc_setOptionSmbEncryptionLevel: void (SMBCCTX *, smbc_smb_encrypt_level) >+smbc_setOptionUrlEncodeReaddirEntries: void (SMBCCTX *, smbc_bool) >+smbc_setOptionUseCCache: void (SMBCCTX *, smbc_bool) >+smbc_setOptionUseKerberos: void (SMBCCTX *, smbc_bool) >+smbc_setOptionUseNTHash: void (SMBCCTX *, smbc_bool) >+smbc_setOptionUserData: void (SMBCCTX *, void *) >+smbc_setPort: void (SMBCCTX *, uint16_t) >+smbc_setServerCacheData: void (SMBCCTX *, struct smbc_server_cache *) >+smbc_setTimeout: void (SMBCCTX *, int) >+smbc_setUser: void (SMBCCTX *, char *) >+smbc_setWorkgroup: void (SMBCCTX *, char *) >+smbc_set_context: SMBCCTX *(SMBCCTX *) >+smbc_set_credentials: void (const char *, const char *, const char *, smbc_bool, const char *) >+smbc_set_credentials_with_fallback: void (SMBCCTX *, const char *, const char *, const char *) >+smbc_setxattr: int (const char *, const char *, const void *, size_t, int) >+smbc_stat: int (const char *, struct stat *) >+smbc_statvfs: int (char *, struct statvfs *) >+smbc_telldir: off_t (int) >+smbc_thread_impl: void (int (*)(const char *, void **, const char *), void (*)(void *, const char *), int (*)(void *, int, const char *), int (*)(const char *, void **, const char *), void (*)(void **, const char *), int (*)(void *, const void *, const char *), void *(*)(void *, const char *)) >+smbc_thread_posix: void (void) >+smbc_unlink: int (const char *) >+smbc_unlink_print_job: int (const char *, int) >+smbc_urldecode: int (char *, char *, size_t) >+smbc_urlencode: int (char *, char *, int) >+smbc_utime: int (const char *, struct utimbuf *) >+smbc_utimes: int (const char *, struct timeval *) >+smbc_version: const char *(void) >+smbc_write: ssize_t (int, const void *, size_t) >diff --git a/source3/libsmb/wscript b/source3/libsmb/wscript >index 4f8b217..c9c566d 100644 >--- a/source3/libsmb/wscript >+++ b/source3/libsmb/wscript >@@ -3,6 +3,9 @@ > import Options, Logs > > def build(bld): >+ libsmbclient_extra_src = '' >+ if bld.CONFIG_SET('HAVE_PTHREAD'): >+ libsmbclient_extra_src = 'libsmb_thread_posix.c' > bld.SAMBA3_LIBRARY('smbclient', > source=''' > libsmb_cache.c >@@ -16,16 +19,20 @@ def build(bld): > libsmb_server.c > libsmb_stat.c > libsmb_xattr.c >- libsmb_setget.c''', >+ libsmb_setget.c >+ libsmb_thread_impl.c >+ ''' + libsmbclient_extra_src, > public_deps=''' > talloc > param > libsmb > KRBCLIENT > msrpc3 >- libcli_lsa3''', >+ libcli_lsa3 >+ samba-util >+ ''', > public_headers='../include/libsmbclient.h', > abi_directory='ABI', > abi_match='smbc_*', >- vnum='0.2.3', >+ vnum='0.2.4', > pc_files='smbclient.pc') >-- >2.5.0.457.gab17608 > > >From f0efb30295b0fb4403df67b9edd34b257a0b4613 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Fri, 4 Sep 2015 13:48:02 -0700 >Subject: [PATCH 2/3] Remove the auto-init from talloc_stackframe() (which > doesn't work with helgrind or drd) and replace with an implicit > talloc_stackframe_thread_init() call. > >Change smbc_thread_posix() to call talloc_stackframe_thread_init(). > >Gets libsmbclient further along the thread-safety >route. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=11413 > >Signed-off-by: Jeremy Allison <jra@samba.org> >--- > lib/util/talloc_stack.c | 7 +------ > lib/util/talloc_stack.h | 2 ++ > source3/libsmb/libsmb_thread_posix.c | 1 + > 3 files changed, 4 insertions(+), 6 deletions(-) > >diff --git a/lib/util/talloc_stack.c b/lib/util/talloc_stack.c >index 9c72c80..28b7214 100644 >--- a/lib/util/talloc_stack.c >+++ b/lib/util/talloc_stack.c >@@ -55,10 +55,7 @@ struct talloc_stackframe { > > static void *global_ts; > >-/* Variable to ensure TLS value is only initialized once. */ >-static smb_thread_once_t ts_initialized = SMB_THREAD_ONCE_INIT; >- >-static void talloc_stackframe_init(void * unused) >+void talloc_stackframe_thread_init(void) > { > if (SMB_THREAD_CREATE_TLS("talloc_stackframe", global_ts)) { > smb_panic("talloc_stackframe_init create_tls failed"); >@@ -82,8 +79,6 @@ static struct talloc_stackframe *talloc_stackframe_create(void) > smb_panic("talloc_stackframe_init malloc failed"); > } > >- SMB_THREAD_ONCE(&ts_initialized, talloc_stackframe_init, NULL); >- > if (SMB_THREAD_SET_TLS(global_ts, ts)) { > smb_panic("talloc_stackframe_init set_tls failed"); > } >diff --git a/lib/util/talloc_stack.h b/lib/util/talloc_stack.h >index 2f5dcab..55e1114 100644 >--- a/lib/util/talloc_stack.h >+++ b/lib/util/talloc_stack.h >@@ -64,4 +64,6 @@ TALLOC_CTX *_talloc_tos(const char *location); > > bool talloc_stackframe_exists(void); > >+void talloc_stackframe_thread_init(void); >+ > #endif >diff --git a/source3/libsmb/libsmb_thread_posix.c b/source3/libsmb/libsmb_thread_posix.c >index 8c8299d..9e2c805 100644 >--- a/source3/libsmb/libsmb_thread_posix.c >+++ b/source3/libsmb/libsmb_thread_posix.c >@@ -49,5 +49,6 @@ void > smbc_thread_posix(void) > { > smb_thread_set_functions(&tf); >+ talloc_stackframe_thread_init(); > } > >-- >2.5.0.457.gab17608 > > >From 49faea643a0b514ef3d3fe426b71c643c1983b6f Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Fri, 4 Sep 2015 13:48:29 -0700 >Subject: [PATCH 3/3] Remove the premature optimization in > smb_threads_internal.h. > >Helps pass more of helgrind/drd. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=11413 > >Signed-off-by: Jeremy Allison <jra@samba.org> >--- > lib/util/smb_threads_internal.h | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > >diff --git a/lib/util/smb_threads_internal.h b/lib/util/smb_threads_internal.h >index afd7559..c098d22 100644 >--- a/lib/util/smb_threads_internal.h >+++ b/lib/util/smb_threads_internal.h >@@ -41,10 +41,8 @@ > > #define SMB_THREAD_ONCE(ponce, init_fn, pdata) \ > (global_tfp \ >- ? (! *(ponce) \ >- ? smb_thread_once((ponce), (init_fn), (pdata)) \ >- : 0) \ >- : ((init_fn(pdata)), *(ponce) = true, 1)) >+ ? smb_thread_once((ponce), (init_fn), (pdata)) \ >+ : (! *(ponce) ? ((init_fn(pdata)), *(ponce) = true, 1) : 0)) > > #define SMB_THREAD_CREATE_TLS(keyname, key) \ > (global_tfp ? global_tfp->create_tls((keyname), &(key), __location__) : 0) >-- >2.5.0.457.gab17608 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 11413
:
11286
|
11303
| 11412