https://bugs.openldap.org/show_bug.cgi?id=10074
Issue ID: 10074 Summary: lloadd: build broken with more recent versions of LLVM Product: OpenLDAP Version: 2.6.4 Hardware: All OS: FreeBSD Status: UNCONFIRMED Keywords: needs_review Severity: normal Priority: --- Component: lloadd Assignee: bugs@openldap.org Reporter: delphij@freebsd.org Target Milestone: ---
There are two issues preventing lloadd from building with more recent versions of LLVM. These are discovered on FreeBSD but may affect other operating systems too.
The first one is that ldap_pvt_thread_self is returning pthread_t (which is a pointer of struct pthread) on FreeBSD, but evthread_set_id_callback was expecting unsigned long.
A possible solution would be to create a wrapper for the function, like:
--- servers/lloadd/libevent_support.c.orig 2023-02-08 18:53:35 UTC +++ servers/lloadd/libevent_support.c @@ -131,6 +131,20 @@ lload_libevent_cond_timedwait( return ldap_pvt_thread_cond_wait( cond, mutex ); }
+/* + * libevent2 expects the thread id has a type of unsigned long. + */ +static unsigned long +lload_libevent_thread_self(void) +{ + unsigned long retval; + static_assert(sizeof(ldap_pvt_thread_t) <= sizeof(unsigned long), + "ldap_pvt_thread_t has to be smaller or equal to unsigned long"); + + retval = (unsigned long)ldap_pvt_thread_self(); + return (retval); +} + int lload_libevent_init( void ) { @@ -152,7 +166,7 @@ lload_libevent_init( void )
evthread_set_lock_callbacks( &cbs ); evthread_set_condition_callbacks( &cond_cbs ); - evthread_set_id_callback( ldap_pvt_thread_self ); + evthread_set_id_callback( lload_libevent_thread_self ); return 0; }
Or, maybe the code should just use evthread_use_pthreads() instead? (It's not very clear to me why we have the ldap_pvt_thread_self wrapper).
Another issue is that module_init.c is trying to assign config_generic_wrapper to bi->bi_config:
module_init.c:154:19: error: incompatible function pointer types assigning to 'BI_config *' (aka 'int (*)(struct BackendInfo *, const char *, int, int, char **)') from 'int (Backend *, const char *, int, int, char **)' (aka 'int (struct BackendDB *, const char *, int, int, char **)') [-Wincompatible-function-pointer-types] bi->bi_config = config_generic_wrapper; ^ ~~~~~~~~~~~~~~~~~~~~~~
For other backends, it's used as bi_db_config. It seems that I can set bi_config to NULL and bi_db_config to config_generic_wrapper, but it's not clear to me what the original intention was...
https://bugs.openldap.org/show_bug.cgi?id=10074
--- Comment #1 from Ondřej Kuzník ondra@mistotebe.net --- Hi, thanks for the report. I think the bi_config is a holdout from when lloadd didn't have cn=config support yet and is not needed anymore. In terms of the id callback, your proposal of a wrapper looks like a manageable solution, could you check if the concerns here are relevant here:
https://github.com/libevent/libevent/commit/fbaf0770a709aaf7ed50914e26ea3d5a...
https://bugs.openldap.org/show_bug.cgi?id=10074
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |2.5.17 Assignee|bugs@openldap.org |ondra@mistotebe.net Keywords|needs_review |
https://bugs.openldap.org/show_bug.cgi?id=10074
--- Comment #2 from Quanah Gibson-Mount quanah@openldap.org --- • de89b06b by Ondřej Kuzník at 2023-08-23T01:21:15+00:00 ITS#10074 Fix type mismatches in lloadd
https://bugs.openldap.org/show_bug.cgi?id=10074
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED
--- Comment #3 from Quanah Gibson-Mount quanah@openldap.org --- RE26:
• 7a647521 by Ondřej Kuzník at 2023-10-23T19:18:23+00:00 ITS#10074 Fix type mismatches in lloadd
RE25:
• b3c54393 by Ondřej Kuzník at 2023-10-23T19:18:27+00:00 ITS#10074 Fix type mismatches in lloadd
https://bugs.openldap.org/show_bug.cgi?id=10074
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |VERIFIED