Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash caused by free of uninitialized pointer #223

Merged
merged 1 commit into from
Aug 7, 2014

Conversation

maep--
Copy link
Contributor

@maep-- maep-- commented Aug 6, 2014

No description provided.

richardgv added a commit that referenced this pull request Aug 7, 2014
fix crash caused by free of uninitialized pointer
@richardgv richardgv merged commit 82242f5 into chjj:master Aug 7, 2014
@richardgv
Copy link
Collaborator

Yes. that's possible, and thanks for the patch.

I looked into libX11-1.6.2's source code. Seemingly it would happen when X fails to allocate memory or _XlcOpenConverter() fails -- sounds like very rare cases. Could you please provide us some information about how you triggered the issue?

@maep--
Copy link
Contributor Author

maep-- commented Aug 7, 2014

I started compton without any extra flags and no config file. It crashed on the first call to make_text_prop function().

card: radeon HD 7850 using open source radeon drivers.
xorg: 1.16.0
libx11: 1.6.2
kernel: 3.15.8-1-ARCH

crash message before my fix (revision 4f9050f):

*** Error in `./compton': free(): invalid pointer: 0x00007f1c6a720380 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x73f8e)[0x7f1c6a3ecf8e]
/usr/lib/libc.so.6(+0x7988e)[0x7f1c6a3f288e]
/usr/lib/libc.so.6(+0x7a04b)[0x7f1c6a3f304b]
/usr/lib/libX11.so.6(XFree+0x9)[0x7f1c6b1ded79]
./compton[0x40781d]
./compton[0x408c8b]
./compton[0x408cd0]
./compton[0x413e8f]
./compton[0x4193b7]
./compton[0x41a39c]
/usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7f1c6a399000]
./compton[0x406a29]

compiled with -fsanitize=address I a decent stacktrace:

ASAN:SIGSEGV
=================================================================
==3174==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f6f6eb2089d sp 0x7fff330db580 bp 0xbebebebebebebebe T0)
    #0 0x7f6f6eb2089c (/usr/lib/libasan.so.1+0x1e89c)
    #1 0x7f6f6eb59894 in __interceptor_free (/usr/lib/libasan.so.1+0x57894)
    #2 0x7f6f6d810d78 in XFree (/usr/lib/libX11.so.6+0x44d78)
    #3 0x408fa2 in cxfree src/common.h:1834
    #4 0x40c6fa in make_text_prop src/compton.h:357
    #5 0x40c73f in wid_set_text_prop src/compton.h:371
    #6 0x42a52e in register_cm src/compton.c:4784
    #7 0x43823c in session_init src/compton.c:7248
    #8 0x43abd3 in main src/compton.c:7639
    #9 0x7f6f6c9cafff in __libc_start_main (/usr/lib/libc.so.6+0x1ffff)
    #10 0x407048 (/home/maep/code/compton/compton+0x407048)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ??:0 ??
==3174==ABORTING

I hope this helps. I don't know much about X11 but I'd be glad to do a bit of testing / debugging as far as my time allows.

edit: after the fix git this message

wid_set_text_prop("git-v0.1_beta2-44-g82242f5-2014-08-07"): Failed to make text property.
register_cm(): Failed to set COMPTON_VERSION.

@richardgv
Copy link
Collaborator

Sorry for the very late reply. I forgot about the issue.

It might have something to do with locale? I'm not able to reproduce the issue by trying different combinations of locales of compton and X here. Anyway, it isn't fatal. Thanks for the info!

@maep--
Copy link
Contributor Author

maep-- commented Feb 9, 2015

My locale is en_DK.UTF-8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants