# createSound() crashing on createSoundInternal()

**URL:** <https://qa.fmod.com/t/createsound-crashing-on-createsoundinternal/16905>\
**Category:** FMOD Engine\
**Created:** [March 19, 2021, 12:51am UTC](https://qa.fmod.com/t/createsound-crashing-on-createsoundinternal/16905 "2021-03-19T00:51:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![emptyclip](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@emptyclip](https://qa.fmod.com/u/emptyclip)\
**Post date:** [March 19, 2021, 12:51am UTC](https://qa.fmod.com/t/createsound-crashing-on-createsoundinternal/16905/1 "2021-03-19T00:51:23Z")

</div>

Hey guys,  
I’m getting a crash attempting to create a sound with in-memory data:

```auto
FMOD_CREATESOUNDEXINFO createSoundEXInfo;
memset(&createSoundEXInfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
createSoundEXInfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
createSoundEXInfo.length = uiSampleLen - uiOffset;
createSoundEXInfo.numchannels = 1;
createSoundEXInfo.defaultfrequency = 11025;
createSoundEXInfo.format = FMOD_SOUND_FORMAT_PCM8;
createSoundEXInfo.suggestedsoundtype = FMOD_SOUND_TYPE_RAW;
const char *pSoundData = (const char *)(ptr + uiOffset);
int iFlags = FMOD_2D | FMOD_OPENMEMORY;
if (bLoop)
{
    iFlags |= FMOD_LOOP_NORMAL;
}
FMOD_RESULT result = mp_pFMODStudioCoreSystem->createSound(pOffsetSoundData, iFlags, &createSoundEXInfo, &mp_pSound);

```

Am I missing parameters to the FMOD\_CREATESOUNDEXINFO structure? The sound data is correct 8-bit PCM, mono 11.025 kHz data, etc.

Call stack (probably not helpful):

```auto
FMOD::SystemI::createSoundInternal (0x8190ACC)
FMOD::SystemI::createSound (0x810BEF8)
FMOD::System::createSound (0x8105798)

```

It’s corrupting the stack.  
Here’s the logged output:

```auto
[LOG] SystemI::createSoundInternal : Create data=0x20944f7388, mode=0x00000808
[LOG] SystemI::createSoundInternal : exinfo->cbsize = 224
[LOG] SystemI::createSoundInternal : exinfo->length = 41154
[LOG] SystemI::createSoundInternal : exinfo->numchannels = 1
[LOG] SystemI::createSoundInternal : exinfo->defaultfrequency = 11025
[LOG] SystemI::createSoundInternal : exinfo->format = 1
[LOG] SystemI::createSoundInternal : exinfo->suggestedsoundtype = 12
[ERR] CodecOggVorbis::openInternal : failed to open as ogg
[ERR] CodecMOD::openInternal : 'M.K.' etc ID check failed [■■■■]
[ERR] CodecS3M::openInternal : 'SCRM' ID check failed [■■■■]
[ERR] CodecXM::openInternal : 'Extended Module: ' ID check failed [■■■■]
[ERR] CodecIT::openInternal : 'IMPM' etc ID check failed [■■■■]
[ERR] CodecMIDI::openInternal : 'HThd' ID check failed [■■■■]

```

… it crashes here.

Shouldn’t the `suggestedSoundType` variable make FMOD open the data as RAW PCM data?

This is on version 0x00020011.

Matt

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [March 19, 2021, 4:52am UTC](https://qa.fmod.com/t/createsound-crashing-on-createsoundinternal/16905/2 "2021-03-19T04:52:09Z")

</div>

Instead of suggestedSoundType, try using [FMOD\_OPENRAW](https://fmod.com/resources/documentation-api?version=2.1&page=core-api-common.html#fmod_openraw) with FMOD::System::createSound().

---

<div class="post-metadata">

**Author:** ![emptyclip](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@emptyclip](https://qa.fmod.com/u/emptyclip)\
**Post date:** [March 19, 2021, 8:31pm UTC](https://qa.fmod.com/t/createsound-crashing-on-createsoundinternal/16905/3 "2021-03-19T20:31:43Z")

</div>

Hey Matthew,  
That totally did it :). May I ask why what I did wouldn’t work? E.g. the suggested format

Matt

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [March 21, 2021, 11:08pm UTC](https://qa.fmod.com/t/createsound-crashing-on-createsoundinternal/16905/4 "2021-03-21T23:08:26Z")

</div>

Firstly, it should not crash, can you confirm whether it crashed or simply return FMOD\_ERR\_FORMAT?  
I did a quick test using your settings and I get the error.

The reason what you did didn’t work was because suggestedSoundType is a hint for the codec scanner, however there is no way to uniquely identify RAW audio (i.e. there is no unique ID at the start of the file). So for RAW we require the createSound flag to specifically say that’s what you are providing, there is no need to set the suggestedSoundType for this case.

---

<div class="post-metadata">

**Author:** ![emptyclip](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@emptyclip](https://qa.fmod.com/u/emptyclip)\
**Post date:** [March 26, 2021, 7:25pm UTC](https://qa.fmod.com/t/createsound-crashing-on-createsoundinternal/16905/5 "2021-03-26T19:25:56Z")

</div>

Hey Matt,  
It was a stack corruption crash. This was on the Switch, btw. I haven’t tried PC or other consoles, but it sounds like this may be part of the detection code with my rogue FMOD\_SOUND\_TYPE\_RAW.

Let me know if that helps at all!

Thanks again for the support!

Matt

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [March 29, 2021, 11:20pm UTC](https://qa.fmod.com/t/createsound-crashing-on-createsoundinternal/16905/6 "2021-03-29T23:20:29Z")

</div>

Thanks for the details, unfortunately (fortunately?) I am unable to get it to crash with your setup (even on Switch). I can confirm the exact same exinfo parameters going on, however I get FMOD\_ERR\_FORMAT. If you’re willing to share the asset I could test with that too.

---

<div class="post-metadata">

**Author:** ![emptyclip](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@emptyclip](https://qa.fmod.com/u/emptyclip)\
**Post date:** [March 30, 2021, 7:40pm UTC](https://qa.fmod.com/t/createsound-crashing-on-createsoundinternal/16905/7 "2021-03-30T19:40:57Z")

</div>

Hey Matt,  
Could you PM offline?

Matt

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [March 30, 2021, 9:49pm UTC](https://qa.fmod.com/t/createsound-crashing-on-createsoundinternal/16905/8 "2021-03-30T21:49:08Z")

</div>

Done, I’ve sent you an email.
