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

Heap-use-after free with real-time settings #733

Closed
derselbst opened this issue Jan 2, 2021 · 1 comment
Closed

Heap-use-after free with real-time settings #733

derselbst opened this issue Jan 2, 2021 · 1 comment
Labels
Milestone

Comments

@derselbst
Copy link
Member

While writing tests for #727 I found another heap-use-after free:

fluid_settings_t *settings = new_fluid_settings();
fluid_synth_t * synth = new_fluid_synth();
delete_fluid_synth(synth);

// crashes here, because the real-time setting tries to make a callback to the deleted synth instance
fluid_settings_setint(settings, "synth.polyphony", 2);
@derselbst derselbst added the bug label Jan 2, 2021
@derselbst derselbst added this to the 2.1 milestone Jan 2, 2021
@derselbst
Copy link
Member Author

=================================================================
==11608==ERROR: AddressSanitizer: heap-use-after-free on address 0x614000000050 at pc 0x0000004bd630 bp 0x7ffdb9f2cd40 sp 0x7ffdb9f2cd38
READ of size 4 at 0x614000000050 thread T0
    #0 0x4bd62f in fluid_synth_api_enter /fluidsynth/src/synth/fluid_synth.c:6596
    #1 0x4ac754 in fluid_synth_set_polyphony /fluidsynth/src/synth/fluid_synth.c:3231
    #2 0x4ac712 in fluid_synth_handle_polyphony /fluidsynth/src/synth/fluid_synth.c:3215
    #3 0x43d213 in fluid_settings_setint /fluidsynth/src/utils/fluid_settings.c:1559
    #4 0x40f3b5 in main /fluidsynth/test/test_sfont_unloading.c:193
    #5 0x7fbc3ceb5349 in __libc_start_main (/lib64/libc.so.6+0x24349)
    #6 0x40ca79 in _start (/fluidsynth/build/test/test_sfont_unloading+0x40ca79)

0x614000000050 is located 16 bytes inside of 400-byte region [0x614000000040,0x6140000001d0)
freed by thread T0 here:
    #0 0x7fbc4017a1a8 in __interceptor_free (/usr/lib64/libasan.so.4+0xdc1a8)
    #1 0x4402ab in fluid_free /fluidsynth/src/utils/fluid_sys.c:232
    #2 0x4a15d5 in delete_fluid_synth /fluidsynth/src/synth/fluid_synth.c:1145
    #3 0x40f07a in test_default_polyphony /fluidsynth/test/test_sfont_unloading.c:179
    #4 0x40f387 in main /fluidsynth/test/test_sfont_unloading.c:190
    #5 0x7fbc3ceb5349 in __libc_start_main (/lib64/libc.so.6+0x24349)

previously allocated by thread T0 here:
    #0 0x7fbc4017a500 in malloc (/usr/lib64/libasan.so.4+0xdc500)
    #1 0x44025a in fluid_alloc /fluidsynth/src/utils/fluid_sys.c:203
    #2 0x49cd93 in new_fluid_synth /fluidsynth/src/synth/fluid_synth.c:622
    #3 0x40dbd3 in test_default_polyphony /fluidsynth/test/test_sfont_unloading.c:113
    #4 0x40f387 in main /fluidsynth/test/test_sfont_unloading.c:190
    #5 0x7fbc3ceb5349 in __libc_start_main (/lib64/libc.so.6+0x24349)

SUMMARY: AddressSanitizer: heap-use-after-free /fluidsynth/src/synth/fluid_synth.c:6596 in fluid_synth_api_enter
Shadow bytes around the buggy address:
  0x0c287fff7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c287fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c287fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c287fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c287fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c287fff8000: fa fa fa fa fa fa fa fa fd fd[fd]fd fd fd fd fd
  0x0c287fff8010: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fff8020: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fff8030: fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa
  0x0c287fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c287fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==11608==ABORTING

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

No branches or pull requests

1 participant