Opened 11 years ago

Closed 10 years ago

Last modified 9 years ago

#7404 closed defect (fixed)

trivial chat-invited signal handler causes crash

Reported by: jieryn Owned by: deryni
Milestone: 2.5.4 Component: plugins
Version: 2.5.2 Keywords: perl


Being habitually lazy, I wanted to automatically accept all chat invitations sent to me for a particular account. I am trying the base case first, accepting all invitations, which is causing a crash on 2.5.2 and lower (went back to 2.4.3, same result).

I am attaching the backtrace as well as the very short perl plugin which triggers it.

Attachments (3)

a (7.2 KB) - added by jieryn 11 years ago.
backtrace full (2.1 KB) - added by jieryn 11 years ago. plugin
perl_va_arg_fix.diff (2.0 KB) - added by deryni 10 years ago.

Download all attachments as: .zip

Change History (14)

Changed 11 years ago by jieryn

  • Attachment a added

backtrace full

Changed 11 years ago by jieryn plugin

comment:1 Changed 11 years ago by deryni

  • Component changed from unclassified to plugins
  • Keywords perl added
  • Owner lschiere deleted

comment:2 Changed 11 years ago by zdeqb

This is a shot in the dark, but I was having crashes in perl signal handlers, until I changed the following lines in perl-handlers.c:perl_signal_cb

298         sv_args[i] = purple_perl_sv_from_vargs(values[i],
299                                                (va_list*)&args,
300                                                &copy_args[i]);


298         sv_args[i] = purple_perl_sv_from_vargs(values[i],
299                                                args,
300                                                &copy_args[i]);

This is on an x86_64. On an i386 the unmodified code works for me (and the modified causes bad thing to happen (tm)). Google says this has to do with va_list(s) being special...

(I was about to file a bug report, but since this looked similar, I thought I'd comment before creating a new ticket...)

comment:3 Changed 11 years ago by jieryn

I verify that this simple update works for me on my x86_64 machine, and my plugin to automatically accept chat invitations is happy.

Devs, please fix this! :-)

comment:4 Changed 10 years ago by deryni

  • Owner set to deryni

comment:5 Changed 10 years ago by zdeqb

I'm trying to refresh my memory here, so I may be a bit off, but:

The reason for the crash, is that args on x86_64 is an array, not a pointer, as on i386 (and other platforms), per [1].

va_copy could be used, but that's C99, and, if I remember correctly, C89 is aimed for.

Some automake/autoconf magic could also be used...

I put together a patch [2], which, using copy-and-paste bypassed the need for passing a va_list around, but it's not exactly a fix (I last looked at the patch a month ago, but I think it worked... if it doesn't, I wouldn't be too surprised)

I'll take another look at this, when I have some time... but if someone fixes it before me, I won't complain ;-)



Changed 10 years ago by deryni

comment:6 Changed 10 years ago by deryni

zdeqb, can you try the patch I just attached and see if it works for both architectures? I may have the ifdef backwards in the second hunk so that may need to be reversed. I'm also not sure if that is enough of a fix, but given your comment from two months ago it might be.

comment:7 Changed 10 years ago by zdeqb

The patch fixes the crash on my x86_64 machine, and the i386 machine keeps on working.

(using autoconf magic also makes for a cleaner patch... ;-)

comment:8 Changed 10 years ago by deryni@…

  • Milestone set to 2.5.4
  • Resolution set to fixed
  • Status changed from new to closed

(In 8b25c4f4ddcd70f0b21bc6bef1867d6df8b25075):
Apparently our use of va_list arguments in the perl signal callbacks doesn't work on x86_64 (and other architectures where a va_list is not a pointer but an array).

Pull an autoconf macro from Glib svn to check whether va_lists are arrays and switch how we use them on that.

I'm not at all sure this is a complete fix but it seems to fix the issue as currently reported.

Fixes #7404

comment:9 Changed 10 years ago by deryni

Ticket #4884 has been marked as a duplicate of this ticket.

comment:10 Changed 10 years ago by deryni

Ticket #3775 has been marked as a duplicate of this ticket.

comment:11 Changed 9 years ago by markdoliner@…

(In 18b85ae6ad8091af43d91826cf054e4569ba74aa):
Pass around a va_list instead of a pointer to a va_list. Refs #7404 This gets rid of a compile warning for me on x86_64. I don't have an i386 box to test on, but every bit of evidence I can find tells me that it's totally fine to pass around a va_list. We do it in status.c

If this breaks compilation for you or you get a warning from perl-handlers.c then pleaes let me know! Or just disapprove this

Note: See TracTickets for help on using tickets.
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!