# Juce Message Thread (1): EXC\_BAD\_ACCESS

**URL:** <https://forum.juce.com/t/juce-message-thread-1-exc-bad-access/26062>\
**Category:** General JUCE discussion\
**Created:** [January 21, 2018, 7:44pm UTC](https://forum.juce.com/t/juce-message-thread-1-exc-bad-access/26062 "2018-01-21T19:44:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pajczur](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pajczur](https://forum.juce.com/u/pajczur)\
**Post date:** [January 21, 2018, 7:44pm UTC](https://forum.juce.com/t/juce-message-thread-1-exc-bad-access/26062/1 "2018-01-21T19:44:19Z")

</div>

Hello,  
I have that error: Juce Message Thread (1): EXC\_BAD\_ACCESS (code=1, address=0x1c8)  
But xCode compiles my code with no error. Such error happens only when I open compiled app. I am not sure why but I’ve seen somewhere and my intuition tells me that to repair that I need to use:

> if ((mojVoice = dynamic\_cast\<WojtekSynthVoice\*\>(mojSynt.getVoice(i))))

but that solution works in processBlock function. But I need to set up sample rate for my SynthesiserVoice, so in my opinion it would be better to set it in prepareToPlay. But I am not sure how to use dynamic\_cast. Could anyone help? Thanks in advance.

---

<div class="post-metadata">

**Author:** ![matkatmusic](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@matkatmusic](https://forum.juce.com/u/matkatmusic)\
**Post date:** [January 21, 2018, 9:08pm UTC](https://forum.juce.com/t/juce-message-thread-1-exc-bad-access/26062/2 "2018-01-21T21:08:41Z")

</div>

EXC\_BAD\_ACCESS means that whatever address you’re trying to access is invalid. So, use your debugger to see what variable in the current scope is nullptr. Also, go read [en.cppreference.com](http://en.cppreference.com) for how to use dynamic\_cast
