getsentry / sentry-native

Sentry SDK for C, C++ and native applications.
MIT License
405 stars 170 forks source link

Heap corruption #710

Open AndreyMlashkin opened 2 years ago

AndreyMlashkin commented 2 years ago

Description

When does the problem happen

Environment

Steps To Reproduce

void updateUserMail(const QString& userIdentifier) { sentry_value_t user = sentry_value_new_object(); sentry_value_set_by_key(user, "email", sentry_value_new_string(userIdentifier.toLocal8Bit().constData())); sentry_set_user(user); } Log output Debug build produces such output: HEAP: Free Heap block 0000013043A00E60 modified at 0000013043A00F28 after it was freed

11 sentry_malloc sentry_alloc.c 22 0x7ff702367f05 12 reserve sentry_value.c 124 0x7ff70236216b 13 sentry_value_set_by_key sentry_value.c 459 0x7ff70235fc9f 14 sentry__get_os_context sentry_os.c 37 0x7ff7023998fe 15 get_scope sentry_scope.c 75 0x7ff702396cad 16 sentry__scope_lock sentry_scope.c 112 0x7ff7023960d7 17 sentry_set_user sentry_core.c 600 0x7ff702365393

Swatinem commented 2 years ago

Hi!

Is the environment you provided correct? You mention qt: false, but that QString sounds very much like qt.

Either way, the stack trace you posted points directly to malloc; is that the allocation that was being modified? Or the code that did the modification? Probably the former, since I doubt system malloc will itself use-after-free.

Can you reproduce this if you set a null user?

AndreyMlashkin commented 2 years ago

Yes. maybe I will need to set qt flag to true. But that's not really related to the issue I think.

I don't modify any sentry code, the only code I use are 6 lines after "Steps To Reproduce"

If I comment out 'sentry_value_set_by_key', the problem is still there