From: Kai Krakow on
Hello!

I've just upgraded a working setup from postfix 2.5.5 to 2.6.6 on a
Gentoo box. Since then, when postfix/local tries to do user name
expansion (as far as I learned from the backtrace), it segfaults:

------------------------8<----------------------
#0  0x11286469 in vstring_strcpy (vp=0x112b8c50, src=0x0) at vstring.c:409
#1  0x112736d9 in dict_db_lookup (dict=0x112b8bd0, name=0x0) at dict_db.c:200
#2  0x1124a83e in deliver_alias (state=
     {level = 1, msg_attr = {level = 0, fp = 0x112bec50, queue_name =
0x112beb40 "active", queue_id = 0x112be868 "0658546584CA", offset =
218, encoding = 0x11298018 "", sender = 0x11298018 "", dsn_envid =
0x11298018 "", dsn_ret = 0, rcpt = {offset = 191, dsn_orcpt =
0x11298018 "", dsn_notify = 0, orig_addr = 0x112bec00
"AAAA(a)AAAAA.AAAAAAAAA.AA", address = 0x112bec28
"AAAA(a)AAAAA.AAAAAAAAA.AA", u = {status = 0, queue = 0x0, addr_type =
0x0}}, domain = 0x0, local = 0x0, user = 0x0, extension = 0x0,
unmatched = 0x0, owner = 0x0, delivered = 0x0, relay = 0x5cea5943
"local", msg_stats = {incoming_arrival = {tv_sec = 1279051621, tv_usec
= 25651}, active_arrival = {tv_sec = 1279125222, tv_usec = 792273},
agent_handoff = {tv_sec = 1279125222, tv_usec = 906187},
conn_setup_done = {tv_sec = 0, tv_usec = 0}, deliver_done = {tv_sec =
0, tv_usec = 0}, reuse_count = 0}, exp_type = 0, exp_from = 0x0,
request = 0x112be1a8, why = 0x112bed20}, dup_filter = 0x112c0980,
loop_info = 0x112bf038, request = 0x112be1a8}, usr_attr={uid = 0, gid
= 0, home = 0x0, logname = 0x0, shell = 0x0}, name=0x0,
statusp=0x5cea4c48) at alias.c:199
#3  0x11250df9 in deliver_switch (state=
     {level = 1, msg_attr = {level = 0, fp = 0x112bec50, queue_name =
0x112beb40 "active", queue_id = 0x112be868 "0658546584CA", offset =
218, encoding = 0x11298018 "", sender = 0x11298018 "", dsn_envid =
0x11298018 "", dsn_ret = 0, rcpt = {offset = 191, dsn_orcpt =
0x11298018 "", dsn_notify = 0, orig_addr = 0x112bec00
"AAAA(a)AAAAA.AAAAAAAAA.AA", address = 0x112bec28
"AAAA(a)AAAAA.AAAAAAAAA.AA", u = {status = 0, queue = 0x0, addr_type =
0x0}}, domain = 0x0, local = 0x0, user = 0x0, extension = 0x0,
unmatched = 0x0, owner = 0x0, delivered = 0x0, relay = 0x5cea5943
"local", msg_stats = {incoming_arrival = {tv_sec = 1279051621, tv_usec
= 25651}, active_arrival = {tv_sec = 1279125222, tv_usec = 792273},
agent_handoff = {tv_sec = 1279125222, tv_usec = 906187},
conn_setup_done = {tv_sec = 0, tv_usec = 0}, deliver_done = {tv_sec =
0, tv_usec = 0}, reuse_count = 0}, exp_type = 0, exp_from = 0x0,
request = 0x112be1a8, why = 0x112bed20}, dup_filter = 0x112c0980,
loop_info = 0x112bf038, request = 0x112be1a8}, usr_attr={uid = 0, gid
= 0, home = 0x0, logname = 0x0, shell = 0x0}) at recipient.c:135
#4  0x11251af8 in deliver_recipient (state=
     {level = 1, msg_attr = {level = 0, fp = 0x112bec50, queue_name =
0x112beb40 "active", queue_id = 0x112be868 "0658546584CA", offset =
218, encoding = 0x11298018 "", sender = 0x11298018 "", dsn_envid =
0x11298018 "", dsn_ret = 0, rcpt = {offset = 191, dsn_orcpt =
0x11298018 "", dsn_notify = 0, orig_addr = 0x112bec00
"AAAA(a)AAAAA.AAAAAAAAA.AA", address = 0x112bec28
"AAAA(a)AAAAA.AAAAAAAAA.AA", u = {status = 0, queue = 0x0, addr_type =
0x0}}, domain = 0x112c0a7d "AAAAA.AAAAAAAAA.AA", local = 0x112c0a78
"root", user = 0x112c0aa0 "root", extension = 0x0, unmatched = 0x0,
owner = 0x0, delivered = 0x112bec28 "root(a)weser.netactive.de", relay =
0x5cea5943 "local", msg_stats = {incoming_arrival = {tv_sec =
1279051621, tv_usec = 25651}, active_arrival = {tv_sec = 1279125222,
tv_usec = 792273}, agent_handoff = {tv_sec = 1279125222, tv_usec =
906187}, conn_setup_done = {tv_sec = 0, tv_usec = 0}, deliver_done =
{tv_sec = 0, tv_usec = 0}, reuse_count = 0}, exp_type = 0, exp_from =
0x0, request = 0x112be1a8, why = 0x112bed20}, dup_filter = 0x112c0980,
loop_info = 0x112bf038, request = 0x112be1a8}, usr_attr={uid = 0, gid
= 0, home = 0x0, logname = 0x0, shell = 0x0}) at recipient.c:319
#5  0x1124f246 in local_deliver (rqst=0x112be1a8, service=0x5cea5943
"local") at local.c:718
#6  0x1124f3c5 in local_service (stream=0x112bd0c8, service=0x5cea5943
"local", argv=0x5cea5880) at local.c:756
#7  0x11254c53 in single_server_wakeup (fd=14) at single_server.c:262
#8  0x11254e1d in single_server_accept_local (unused_event=1,
context=0x6 <Address 0x6 out of bounds>) at single_server.c:304
#9  0x1127a896 in event_loop (delay=-1) at events.c:1086
#10 0x11255bd6 in single_server_main (argc=3, argv=0x5cea5874,
service=0x1124f351 <local_service>) at single_server.c:732
#11 0x1124f892 in main (argc=3, argv=0x5cea5874) at local.c:917
------------------------8<----------------------

Here's postconf -n:

------------------------8<----------------------
address_verify_map = btree:/var/lib/postfix/verify
alias_database = hash:/etc/mail/aliases
alias_maps = hash:/var/lib/mailman/data/aliases hash:/etc/mail/aliases
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = //usr/lib/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
default_destination_concurrency_limit = 20
default_process_limit = 500
home_mailbox = .maildir/
html_directory = /usr/share/doc/postfix-2.6.6/html
local_destination_concurrency_limit = 2
mail_owner = postfix
mailbox_size_limit = 104857600
mailq_path = /usr/bin/mailq
manpage_directory = /usr/share/man
message_size_limit = 52428800
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydomain = AAAAA.AAAAAAAAA.AA
myhostname = AAAAA.AAAAAAAAA.AA
mynetworks = 127.0.0.0/8, DDD.DDD.DDD.DD, DD.DDD.DD.DD/DD
newaliases_path = /usr/bin/newaliases
queue_directory = /var/spool/postfix
rbl_reply_maps = ${stress?hash:/etc/postfix/rbl_reply_maps}
readme_directory = /usr/share/doc/postfix-2.6.6/readme
recipient_delimiter = +
sendmail_path = /usr/sbin/sendmail
setgid_group = postdrop
smtpd_banner = $myhostname ESMTP $mail_name (AAAAAAAAA Mail Service).
We block/report all spam. We use greylisting.
smtpd_client_connection_count_limit = 50
smtpd_client_connection_rate_limit = 30
smtpd_client_message_rate_limit = 100
smtpd_client_recipient_rate_limit = 2000
smtpd_error_sleep_time = 5s
smtpd_hard_error_limit = ${stress?1}${stress:20}
smtpd_helo_required = yes
smtpd_junk_command_limit = 20
smtpd_recipient_restrictions = reject_unlisted_recipient
reject_unknown_recipient_domain check_recipient_access
hash:/etc/postfix/block_recipients permit_mynetworks
permit_sasl_authenticated reject_unauth_destination
reject_non_fqdn_recipient reject_invalid_helo_hostname
reject_rbl_client zen.spamhaus.org=127.0.0.10 reject_rbl_client
zen.spamhaus.org=127.0.0.11 reject_rbl_client zen.spamhaus.org
check_sender_access hash:/etc/postfix/whitelisted_senders
check_policy_service inet:127.0.0.1:12525 check_policy_service
unix:private/postgrey check_policy_service unix:private/spf
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sender_restrictions = hash:/etc/postfix/sender_access
smtpd_soft_error_limit = 10
smtpd_timeout = ${stress?10}${stress:60}
transport_maps = hash:/etc/postfix/transport
unknown_local_recipient_reject_code = 550
unverified_sender_reject_code = 550
virtual_alias_domains =
virtual_alias_maps = hash:/var/lib/mailman/data/virtual-mailman
proxy:mysql:/etc/postfix/mysql-virtual_alias_maps.cf
virtual_gid_maps = static:2000
virtual_mailbox_base = /data/mailhosts/
virtual_mailbox_domains =
proxy:mysql:/etc/postfix/mysql-virtual_mailbox_domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_maps.cf
virtual_transport = maildrop
virtual_uid_maps = static:2000
------------------------8<----------------------

It looks like deliver_alias() gets passed a null pointer for name,
later in the code path postfix tries to copy a string to this pointer
- thus the segfault. But I cannot figure out why that is and if it'd
be fixable in the config.

Since this is a production system, any help is appreciated. Virtual
users managed by MySQL aren't affected - works like a charm there.
That's why it took some days before the few system users started to
miss mails - the queue has about 2000 deferred mails now. :-(

Regards,
Kai

From: Kai Krakow on
Mystery solved:

Adding "-O2" to CFLAGS (an "-Ox" parameter was missing) solved the problem.
Seems to be an GCC issue. I don't know if postfix should compile and work fine
without this or with another optimizer level.

If someone wants to debug this further: The pointer to the problem is within
src/local/recipient.c:319 when the "state" struct is passed to
deliver_switch(): Just before the call the struct members are set correct, then
on entering the function, the members are reset to the original values on the
stack when deliver_recipient() (the calling function) was entered (and thus
state.msg_attr.local is reset to 0x0).

2010/7/14 Kai Krakow <hurikhan77+postfix(a)googlemail.com>:
> Hello!
>
> I've just upgraded a working setup from postfix 2.5.5 to 2.6.6 on a
> Gentoo box. Since then, when postfix/local tries to do user name
> expansion (as far as I learned from the backtrace), it segfaults:
>
> ------------------------8<----------------------
> #0  0x11286469 in vstring_strcpy (vp=0x112b8c50, src=0x0) at vstring.c:409
> #1  0x112736d9 in dict_db_lookup (dict=0x112b8bd0, name=0x0) at dict_db.c:200
> #2  0x1124a83e in deliver_alias (state=
>      {level = 1, msg_attr = {level = 0, fp = 0x112bec50, queue_name =
> 0x112beb40 "active", queue_id = 0x112be868 "0658546584CA", offset =
> 218, encoding = 0x11298018 "", sender = 0x11298018 "", dsn_envid =
> 0x11298018 "", dsn_ret = 0, rcpt = {offset = 191, dsn_orcpt =
> 0x11298018 "", dsn_notify = 0, orig_addr = 0x112bec00
> "AAAA(a)AAAAA.AAAAAAAAA.AA", address = 0x112bec28
> "AAAA(a)AAAAA.AAAAAAAAA.AA", u = {status = 0, queue = 0x0, addr_type =
> 0x0}}, domain = 0x0, local = 0x0, user = 0x0, extension = 0x0,
> unmatched = 0x0, owner = 0x0, delivered = 0x0, relay = 0x5cea5943
> "local", msg_stats = {incoming_arrival = {tv_sec = 1279051621, tv_usec
> = 25651}, active_arrival = {tv_sec = 1279125222, tv_usec = 792273},
> agent_handoff = {tv_sec = 1279125222, tv_usec = 906187},
> conn_setup_done = {tv_sec = 0, tv_usec = 0}, deliver_done = {tv_sec =
> 0, tv_usec = 0}, reuse_count = 0}, exp_type = 0, exp_from = 0x0,
> request = 0x112be1a8, why = 0x112bed20}, dup_filter = 0x112c0980,
> loop_info = 0x112bf038, request = 0x112be1a8}, usr_attr={uid = 0, gid
> = 0, home = 0x0, logname = 0x0, shell = 0x0}, name=0x0,
> statusp=0x5cea4c48) at alias.c:199
> #3  0x11250df9 in deliver_switch (state=
>      {level = 1, msg_attr = {level = 0, fp = 0x112bec50, queue_name =
> 0x112beb40 "active", queue_id = 0x112be868 "0658546584CA", offset =
> 218, encoding = 0x11298018 "", sender = 0x11298018 "", dsn_envid =
> 0x11298018 "", dsn_ret = 0, rcpt = {offset = 191, dsn_orcpt =
> 0x11298018 "", dsn_notify = 0, orig_addr = 0x112bec00
> "AAAA(a)AAAAA.AAAAAAAAA.AA", address = 0x112bec28
> "AAAA(a)AAAAA.AAAAAAAAA.AA", u = {status = 0, queue = 0x0, addr_type =
> 0x0}}, domain = 0x0, local = 0x0, user = 0x0, extension = 0x0,
> unmatched = 0x0, owner = 0x0, delivered = 0x0, relay = 0x5cea5943
> "local", msg_stats = {incoming_arrival = {tv_sec = 1279051621, tv_usec
> = 25651}, active_arrival = {tv_sec = 1279125222, tv_usec = 792273},
> agent_handoff = {tv_sec = 1279125222, tv_usec = 906187},
> conn_setup_done = {tv_sec = 0, tv_usec = 0}, deliver_done = {tv_sec =
> 0, tv_usec = 0}, reuse_count = 0}, exp_type = 0, exp_from = 0x0,
> request = 0x112be1a8, why = 0x112bed20}, dup_filter = 0x112c0980,
> loop_info = 0x112bf038, request = 0x112be1a8}, usr_attr={uid = 0, gid
> = 0, home = 0x0, logname = 0x0, shell = 0x0}) at recipient.c:135
> #4  0x11251af8 in deliver_recipient (state=
>      {level = 1, msg_attr = {level = 0, fp = 0x112bec50, queue_name =
> 0x112beb40 "active", queue_id = 0x112be868 "0658546584CA", offset =
> 218, encoding = 0x11298018 "", sender = 0x11298018 "", dsn_envid =
> 0x11298018 "", dsn_ret = 0, rcpt = {offset = 191, dsn_orcpt =
> 0x11298018 "", dsn_notify = 0, orig_addr = 0x112bec00
> "AAAA(a)AAAAA.AAAAAAAAA.AA", address = 0x112bec28
> "AAAA(a)AAAAA.AAAAAAAAA.AA", u = {status = 0, queue = 0x0, addr_type =
> 0x0}}, domain = 0x112c0a7d "AAAAA.AAAAAAAAA.AA", local = 0x112c0a78
> "root", user = 0x112c0aa0 "root", extension = 0x0, unmatched = 0x0,
> owner = 0x0, delivered = 0x112bec28 "root(a)weser.netactive.de", relay =
> 0x5cea5943 "local", msg_stats = {incoming_arrival = {tv_sec =
> 1279051621, tv_usec = 25651}, active_arrival = {tv_sec = 1279125222,
> tv_usec = 792273}, agent_handoff = {tv_sec = 1279125222, tv_usec =
> 906187}, conn_setup_done = {tv_sec = 0, tv_usec = 0}, deliver_done =
> {tv_sec = 0, tv_usec = 0}, reuse_count = 0}, exp_type = 0, exp_from =
> 0x0, request = 0x112be1a8, why = 0x112bed20}, dup_filter = 0x112c0980,
> loop_info = 0x112bf038, request = 0x112be1a8}, usr_attr={uid = 0, gid
> = 0, home = 0x0, logname = 0x0, shell = 0x0}) at recipient.c:319
> #5  0x1124f246 in local_deliver (rqst=0x112be1a8, service=0x5cea5943
> "local") at local.c:718
> #6  0x1124f3c5 in local_service (stream=0x112bd0c8, service=0x5cea5943
> "local", argv=0x5cea5880) at local.c:756
> #7  0x11254c53 in single_server_wakeup (fd=14) at single_server.c:262
> #8  0x11254e1d in single_server_accept_local (unused_event=1,
> context=0x6 <Address 0x6 out of bounds>) at single_server.c:304
> #9  0x1127a896 in event_loop (delay=-1) at events.c:1086
> #10 0x11255bd6 in single_server_main (argc=3, argv=0x5cea5874,
> service=0x1124f351 <local_service>) at single_server.c:732
> #11 0x1124f892 in main (argc=3, argv=0x5cea5874) at local.c:917
> ------------------------8<----------------------
>
> Here's postconf -n:
>
> ------------------------8<----------------------
> address_verify_map = btree:/var/lib/postfix/verify
> alias_database = hash:/etc/mail/aliases
> alias_maps = hash:/var/lib/mailman/data/aliases hash:/etc/mail/aliases
> broken_sasl_auth_clients = yes
> command_directory = /usr/sbin
> config_directory = /etc/postfix
> daemon_directory = //usr/lib/postfix
> data_directory = /var/lib/postfix
> debug_peer_level = 2
> default_destination_concurrency_limit = 20
> default_process_limit = 500
> home_mailbox = .maildir/
> html_directory = /usr/share/doc/postfix-2.6.6/html
> local_destination_concurrency_limit = 2
> mail_owner = postfix
> mailbox_size_limit = 104857600
> mailq_path = /usr/bin/mailq
> manpage_directory = /usr/share/man
> message_size_limit = 52428800
> mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
> mydomain = AAAAA.AAAAAAAAA.AA
> myhostname = AAAAA.AAAAAAAAA.AA
> mynetworks = 127.0.0.0/8, DDD.DDD.DDD.DD, DD.DDD.DD.DD/DD
> newaliases_path = /usr/bin/newaliases
> queue_directory = /var/spool/postfix
> rbl_reply_maps = ${stress?hash:/etc/postfix/rbl_reply_maps}
> readme_directory = /usr/share/doc/postfix-2.6.6/readme
> recipient_delimiter = +
> sendmail_path = /usr/sbin/sendmail
> setgid_group = postdrop
> smtpd_banner = $myhostname ESMTP $mail_name (AAAAAAAAA Mail Service).
> We block/report all spam. We use greylisting.
> smtpd_client_connection_count_limit = 50
> smtpd_client_connection_rate_limit = 30
> smtpd_client_message_rate_limit = 100
> smtpd_client_recipient_rate_limit = 2000
> smtpd_error_sleep_time = 5s
> smtpd_hard_error_limit = ${stress?1}${stress:20}
> smtpd_helo_required = yes
> smtpd_junk_command_limit = 20
> smtpd_recipient_restrictions = reject_unlisted_recipient
> reject_unknown_recipient_domain check_recipient_access
> hash:/etc/postfix/block_recipients permit_mynetworks
> permit_sasl_authenticated reject_unauth_destination
> reject_non_fqdn_recipient reject_invalid_helo_hostname
> reject_rbl_client zen.spamhaus.org=127.0.0.10 reject_rbl_client
> zen.spamhaus.org=127.0.0.11 reject_rbl_client zen.spamhaus.org
> check_sender_access hash:/etc/postfix/whitelisted_senders
> check_policy_service inet:127.0.0.1:12525 check_policy_service
> unix:private/postgrey check_policy_service unix:private/spf
> smtpd_sasl_auth_enable = yes
> smtpd_sasl_local_domain = $myhostname
> smtpd_sasl_path = private/auth
> smtpd_sasl_security_options = noanonymous
> smtpd_sasl_type = dovecot
> smtpd_sender_restrictions = hash:/etc/postfix/sender_access
> smtpd_soft_error_limit = 10
> smtpd_timeout = ${stress?10}${stress:60}
> transport_maps = hash:/etc/postfix/transport
> unknown_local_recipient_reject_code = 550
> unverified_sender_reject_code = 550
> virtual_alias_domains =
> virtual_alias_maps = hash:/var/lib/mailman/data/virtual-mailman
> proxy:mysql:/etc/postfix/mysql-virtual_alias_maps.cf
> virtual_gid_maps = static:2000
> virtual_mailbox_base = /data/mailhosts/
> virtual_mailbox_domains =
> proxy:mysql:/etc/postfix/mysql-virtual_mailbox_domains.cf
> virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_maps.cf
> virtual_transport = maildrop
> virtual_uid_maps = static:2000
> ------------------------8<----------------------
>
> It looks like deliver_alias() gets passed a null pointer for name,
> later in the code path postfix tries to copy a string to this pointer
> - thus the segfault. But I cannot figure out why that is and if it'd
> be fixable in the config.
>
> Since this is a production system, any help is appreciated. Virtual
> users managed by MySQL aren't affected - works like a charm there.
> That's why it took some days before the few system users started to
> miss mails - the queue has about 2000 deferred mails now. :-(
>
> Regards,
> Kai
>



--
Regards,
Kai Krakow
http://hurikhan77.wordpress.com/

From: Wietse Venema on
Kai Krakow:
> Mystery solved:
>
> Adding "-O2" to CFLAGS (an "-Ox" parameter was missing) solved the problem.
> Seems to be an GCC issue. I don't know if postfix should compile and work fine
> without this or with another optimizer level.

It *should* work with all optimization levels. except for:

- Bugs in the compiler, where the optimizer breaks valid code.

- Bugs in Postfix, where I rely on behavior that is not promised
by the C standard.

It can require a great deal of time to figure out which the
problem is. Fortunately it looks like you have done most of it.

> If someone wants to debug this further: The pointer to the problem is within
> src/local/recipient.c:319 when the "state" struct is passed to
> deliver_switch(): Just before the call the struct members are set correct, then
> on entering the function, the members are reset to the original values on the
> stack when deliver_recipient() (the calling function) was entered (and thus
> state.msg_attr.local is reset to 0x0).

That would be a compiler bug, possibly compiler version dependent.

C has supported "structure" valued function parameters for about 30
years. Although implementations of this feature have changed, it
should never break when calling a function in the same program that
is compiled with the same compiler options (and the Postfix build
system recompiles all code when you change compiler options with
"make makefiles").

Wietse

> 2010/7/14 Kai Krakow <hurikhan77+postfix(a)googlemail.com>:
> > Hello!
> >
> > I've just upgraded a working setup from postfix 2.5.5 to 2.6.6 on a
> > Gentoo box. Since then, when postfix/local tries to do user name
> > expansion (as far as I learned from the backtrace), it segfaults:
> >
> > ------------------------8<----------------------
> > #0 ?0x11286469 in vstring_strcpy (vp=0x112b8c50, src=0x0) at vstring.c:409
> > #1 ?0x112736d9 in dict_db_lookup (dict=0x112b8bd0, name=0x0) at dict_db.c:200
> > #2 ?0x1124a83e in deliver_alias (state=
> > ? ? ?{level = 1, msg_attr = {level = 0, fp = 0x112bec50, queue_name =
> > 0x112beb40 "active", queue_id = 0x112be868 "0658546584CA", offset =
> > 218, encoding = 0x11298018 "", sender = 0x11298018 "", dsn_envid =
> > 0x11298018 "", dsn_ret = 0, rcpt = {offset = 191, dsn_orcpt =
> > 0x11298018 "", dsn_notify = 0, orig_addr = 0x112bec00
> > "AAAA(a)AAAAA.AAAAAAAAA.AA", address = 0x112bec28
> > "AAAA(a)AAAAA.AAAAAAAAA.AA", u = {status = 0, queue = 0x0, addr_type =
> > 0x0}}, domain = 0x0, local = 0x0, user = 0x0, extension = 0x0,
> > unmatched = 0x0, owner = 0x0, delivered = 0x0, relay = 0x5cea5943
> > "local", msg_stats = {incoming_arrival = {tv_sec = 1279051621, tv_usec
> > = 25651}, active_arrival = {tv_sec = 1279125222, tv_usec = 792273},
> > agent_handoff = {tv_sec = 1279125222, tv_usec = 906187},
> > conn_setup_done = {tv_sec = 0, tv_usec = 0}, deliver_done = {tv_sec =
> > 0, tv_usec = 0}, reuse_count = 0}, exp_type = 0, exp_from = 0x0,
> > request = 0x112be1a8, why = 0x112bed20}, dup_filter = 0x112c0980,
> > loop_info = 0x112bf038, request = 0x112be1a8}, usr_attr={uid = 0, gid
> > = 0, home = 0x0, logname = 0x0, shell = 0x0}, name=0x0,
> > statusp=0x5cea4c48) at alias.c:199
> > #3 ?0x11250df9 in deliver_switch (state=
> > ? ? ?{level = 1, msg_attr = {level = 0, fp = 0x112bec50, queue_name =
> > 0x112beb40 "active", queue_id = 0x112be868 "0658546584CA", offset =
> > 218, encoding = 0x11298018 "", sender = 0x11298018 "", dsn_envid =
> > 0x11298018 "", dsn_ret = 0, rcpt = {offset = 191, dsn_orcpt =
> > 0x11298018 "", dsn_notify = 0, orig_addr = 0x112bec00
> > "AAAA(a)AAAAA.AAAAAAAAA.AA", address = 0x112bec28
> > "AAAA(a)AAAAA.AAAAAAAAA.AA", u = {status = 0, queue = 0x0, addr_type =
> > 0x0}}, domain = 0x0, local = 0x0, user = 0x0, extension = 0x0,
> > unmatched = 0x0, owner = 0x0, delivered = 0x0, relay = 0x5cea5943
> > "local", msg_stats = {incoming_arrival = {tv_sec = 1279051621, tv_usec
> > = 25651}, active_arrival = {tv_sec = 1279125222, tv_usec = 792273},
> > agent_handoff = {tv_sec = 1279125222, tv_usec = 906187},
> > conn_setup_done = {tv_sec = 0, tv_usec = 0}, deliver_done = {tv_sec =
> > 0, tv_usec = 0}, reuse_count = 0}, exp_type = 0, exp_from = 0x0,
> > request = 0x112be1a8, why = 0x112bed20}, dup_filter = 0x112c0980,
> > loop_info = 0x112bf038, request = 0x112be1a8}, usr_attr={uid = 0, gid
> > = 0, home = 0x0, logname = 0x0, shell = 0x0}) at recipient.c:135
> > #4 ?0x11251af8 in deliver_recipient (state=
> > ? ? ?{level = 1, msg_attr = {level = 0, fp = 0x112bec50, queue_name =
> > 0x112beb40 "active", queue_id = 0x112be868 "0658546584CA", offset =
> > 218, encoding = 0x11298018 "", sender = 0x11298018 "", dsn_envid =
> > 0x11298018 "", dsn_ret = 0, rcpt = {offset = 191, dsn_orcpt =
> > 0x11298018 "", dsn_notify = 0, orig_addr = 0x112bec00
> > "AAAA(a)AAAAA.AAAAAAAAA.AA", address = 0x112bec28
> > "AAAA(a)AAAAA.AAAAAAAAA.AA", u = {status = 0, queue = 0x0, addr_type =
> > 0x0}}, domain = 0x112c0a7d "AAAAA.AAAAAAAAA.AA", local = 0x112c0a78
> > "root", user = 0x112c0aa0 "root", extension = 0x0, unmatched = 0x0,
> > owner = 0x0, delivered = 0x112bec28 "root(a)weser.netactive.de", relay =
> > 0x5cea5943 "local", msg_stats = {incoming_arrival = {tv_sec =
> > 1279051621, tv_usec = 25651}, active_arrival = {tv_sec = 1279125222,
> > tv_usec = 792273}, agent_handoff = {tv_sec = 1279125222, tv_usec =
> > 906187}, conn_setup_done = {tv_sec = 0, tv_usec = 0}, deliver_done =
> > {tv_sec = 0, tv_usec = 0}, reuse_count = 0}, exp_type = 0, exp_from =
> > 0x0, request = 0x112be1a8, why = 0x112bed20}, dup_filter = 0x112c0980,
> > loop_info = 0x112bf038, request = 0x112be1a8}, usr_attr={uid = 0, gid
> > = 0, home = 0x0, logname = 0x0, shell = 0x0}) at recipient.c:319
> > #5 ?0x1124f246 in local_deliver (rqst=0x112be1a8, service=0x5cea5943
> > "local") at local.c:718
> > #6 ?0x1124f3c5 in local_service (stream=0x112bd0c8, service=0x5cea5943
> > "local", argv=0x5cea5880) at local.c:756
> > #7 ?0x11254c53 in single_server_wakeup (fd=14) at single_server.c:262
> > #8 ?0x11254e1d in single_server_accept_local (unused_event=1,
> > context=0x6 <Address 0x6 out of bounds>) at single_server.c:304
> > #9 ?0x1127a896 in event_loop (delay=-1) at events.c:1086
> > #10 0x11255bd6 in single_server_main (argc=3, argv=0x5cea5874,
> > service=0x1124f351 <local_service>) at single_server.c:732
> > #11 0x1124f892 in main (argc=3, argv=0x5cea5874) at local.c:917
> > ------------------------8<----------------------
> >
> > Here's postconf -n:
> >
> > ------------------------8<----------------------
> > address_verify_map = btree:/var/lib/postfix/verify
> > alias_database = hash:/etc/mail/aliases
> > alias_maps = hash:/var/lib/mailman/data/aliases hash:/etc/mail/aliases
> > broken_sasl_auth_clients = yes
> > command_directory = /usr/sbin
> > config_directory = /etc/postfix
> > daemon_directory = //usr/lib/postfix
> > data_directory = /var/lib/postfix
> > debug_peer_level = 2
> > default_destination_concurrency_limit = 20
> > default_process_limit = 500
> > home_mailbox = .maildir/
> > html_directory = /usr/share/doc/postfix-2.6.6/html
> > local_destination_concurrency_limit = 2
> > mail_owner = postfix
> > mailbox_size_limit = 104857600
> > mailq_path = /usr/bin/mailq
> > manpage_directory = /usr/share/man
> > message_size_limit = 52428800
> > mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
> > mydomain = AAAAA.AAAAAAAAA.AA
> > myhostname = AAAAA.AAAAAAAAA.AA
> > mynetworks = 127.0.0.0/8, DDD.DDD.DDD.DD, DD.DDD.DD.DD/DD
> > newaliases_path = /usr/bin/newaliases
> > queue_directory = /var/spool/postfix
> > rbl_reply_maps = ${stress?hash:/etc/postfix/rbl_reply_maps}
> > readme_directory = /usr/share/doc/postfix-2.6.6/readme
> > recipient_delimiter = +
> > sendmail_path = /usr/sbin/sendmail
> > setgid_group = postdrop
> > smtpd_banner = $myhostname ESMTP $mail_name (AAAAAAAAA Mail Service).
> > We block/report all spam. We use greylisting.
> > smtpd_client_connection_count_limit = 50
> > smtpd_client_connection_rate_limit = 30
> > smtpd_client_message_rate_limit = 100
> > smtpd_client_recipient_rate_limit = 2000
> > smtpd_error_sleep_time = 5s
> > smtpd_hard_error_limit = ${stress?1}${stress:20}
> > smtpd_helo_required = yes
> > smtpd_junk_command_limit = 20
> > smtpd_recipient_restrictions = reject_unlisted_recipient
> > reject_unknown_recipient_domain check_recipient_access
> > hash:/etc/postfix/block_recipients permit_mynetworks
> > permit_sasl_authenticated reject_unauth_destination
> > reject_non_fqdn_recipient reject_invalid_helo_hostname
> > reject_rbl_client zen.spamhaus.org=127.0.0.10 reject_rbl_client
> > zen.spamhaus.org=127.0.0.11 reject_rbl_client zen.spamhaus.org
> > check_sender_access hash:/etc/postfix/whitelisted_senders
> > check_policy_service inet:127.0.0.1:12525 check_policy_service
> > unix:private/postgrey check_policy_service unix:private/spf
> > smtpd_sasl_auth_enable = yes
> > smtpd_sasl_local_domain = $myhostname
> > smtpd_sasl_path = private/auth
> > smtpd_sasl_security_options = noanonymous
> > smtpd_sasl_type = dovecot
> > smtpd_sender_restrictions = hash:/etc/postfix/sender_access
> > smtpd_soft_error_limit = 10
> > smtpd_timeout = ${stress?10}${stress:60}
> > transport_maps = hash:/etc/postfix/transport
> > unknown_local_recipient_reject_code = 550
> > unverified_sender_reject_code = 550
> > virtual_alias_domains =
> > virtual_alias_maps = hash:/var/lib/mailman/data/virtual-mailman
> > proxy:mysql:/etc/postfix/mysql-virtual_alias_maps.cf
> > virtual_gid_maps = static:2000
> > virtual_mailbox_base = /data/mailhosts/
> > virtual_mailbox_domains =
> > proxy:mysql:/etc/postfix/mysql-virtual_mailbox_domains.cf
> > virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_maps.cf
> > virtual_transport = maildrop
> > virtual_uid_maps = static:2000
> > ------------------------8<----------------------
> >
> > It looks like deliver_alias() gets passed a null pointer for name,
> > later in the code path postfix tries to copy a string to this pointer
> > - thus the segfault. But I cannot figure out why that is and if it'd
> > be fixable in the config.
> >
> > Since this is a production system, any help is appreciated. Virtual
> > users managed by MySQL aren't affected - works like a charm there.
> > That's why it took some days before the few system users started to
> > miss mails - the queue has about 2000 deferred mails now. :-(
> >
> > Regards,
> > Kai
> >
>
>
>
> --
> Regards,
> Kai Krakow
> http://hurikhan77.wordpress.com/
>
>

From: Kai Krakow on
2010/7/21 Wietse Venema <wietse(a)porcupine.org>:
> That would be a compiler bug, possibly compiler version dependent.

Yep, I'm sure it is. The postfix ebuild from gentoo contains some
evidence that hardened gcc 3.4 may be problematic. In case you are
interested, follow up bug report:
http://bugs.gentoo.org/show_bug.cgi?id=328375

--
Regards,
Kai Krakow
http://hurikhan77.wordpress.com/

From: Bas Mevissen on
On 07/21/2010 10:23 PM, Kai Krakow wrote:
> 2010/7/21 Wietse Venema <wietse(a)porcupine.org>:
>> That would be a compiler bug, possibly compiler version dependent.
>
> Yep, I'm sure it is. The postfix ebuild from gentoo contains some
> evidence that hardened gcc 3.4 may be problematic. In case you are
> interested, follow up bug report:
> http://bugs.gentoo.org/show_bug.cgi?id=328375
>


Can you try what happens if you replace at


typedef struct LOCAL_STATE {
int level; /* nesting level, for logging */
DELIVER_ATTR msg_attr; /* message/recipient attributes */
DELIVER_REQUEST *request; /* as from queue manager */
} LOCAL_STATE;


the first line with:

typedef struct local_state {

in virtual.h and same for DELIVER_ATTR and DELIVER_REQUEST?

The difference is that the symbol LOCAL_STATE is now only used once.
Most coding standards forbid to define a symbol more than once.

Bas.

--
Bas