Causes for EXC_BREAKPOINT crash - swift

I have this stack trace in Crashlytics:
The source code are running is below:
#objc private func playerTimerTick() {
mediaDurationInSeconds = Int32(mediaDuration)
mediaCurrentPositionInSeconds = Int32(currentTimeInSeconds)
if elapsedTimeNeedStoreStartPosition {
elapsedTimeNeedStoreStartPosition = false
elapsedTimeStartPosition = mediaCurrentPositionInSeconds
}
}
The line 1092 is mediaDurationInSeconds = Int32(mediaDuration).
The mediaDuration variable is a Double type and receive a duration in seconds from a AVURLAsset.
This method (playerTimerTick) is running by a Timer.scheduledTimer every 1 second. I have already performed several debugs of this source code and this function and there is no crash. But in the release version is occurring with multiple users and without any explanation.
Has anyone ever had anything like this or do you have any idea what might be causing this crash?

Related

"Unable to cast to Dictionary" error occurred when trying to tween

I was trying to make a tween for a text so whenever when player loaded and wait for at least 5 seconds after they loaded in, the text transparency will set to 0 smoothly
Then, I tried to make that happen with a service called TweenService but I was greeted with an error "Unable to cast to Dictionary"
I tried another way by checking the documentation and Forums but didn't find or solve any solutions
Here's my code:
local loadingrobloxos = LoadingAssetsGUI.LoadingBootBackground.LoadingRobloxOS
local goallro = loadingrobloxos.TextTransparency == 0
local tweeninfolro = TweenInfo.new(
0.5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
1,
false
)
local tweenlro = TweenService:Create(loadingrobloxos, tweeninfolro, goallro):Play()
What is actually wrong?
If you look at the documentation for TweenService:Create, you'll see that the last argument of the function is supposed to be a dictionary.
TweenService:Create(loadingrobloxos, tweeninfolro, goallro)
The error is telling you that whatever you passed in for the variable goallro, it cannot be converted to a dictionary. And that line is...
local goallro = loadingrobloxos.TextTransparency == 0
This line is not creating a dictionary, it is asking the question, "is loadingrobloxos's TextTransparency currently set to zero?" So the variable goallro is set to false. TweenService doesn't know what to do with false, so it throws the error.
Instead, try this :
local goallro = {
TextTransparency = 0
}

Message from debugger: Terminated due to memory issue on Initial Load

So I am currently building an app, do display some user analytics. In order to check if all my background calculations and the corresponding plots look descent, I have written a function to generate some mock Data, called addMockData and looks something like this:
func addMockdata() {
let ClassToHoldData = ClassToHoldData()
for i in 0...15 {
let otherClassToHoldData = otherClassToHoldData()
for j in 0...12000 {
let fx = ...
let fy = ...
let fz = ...
fx.append(...)
fy.append(...)
fz.append(...)
}
otherClassToHoldData.fx = fx
otherClassToHoldData.fy = fy
otherClassToHoldData.fz = fz
ClassToHoldData.info.append(otherClassToHoldData)
try! realm.write {
realm.objects(UserModel.self)[index].data.append(ClassToHoldData)
}
}
I call addMockData in the AppDelegate under the application(...) method. Thus when I build and run the app for the first time addMockData gets called. This works fine in the simulator and the data is generated without a hitch and memory usage peaking at around 450 Mb when generating the mock data.
The issue arises when I run the program on an actual device, in my case an Ipad Air (3rd Gen). There after generating roughly half of the mock data, it terminates with the message "Message from debugger: Terminated due to memory issue". The memory usage steadily rises until it reaches roughly 1.7 Gb, when it crashes. It seems like it does not deallocate all the data generated in the for loop.
I have tried wrapping my for loops in a autoreleasepool{} and have checked that Zombie Objects are disabled.
What else could I try? Any help is greatly appreciated!

std::lock_guard (mutex) produces deadlock

First: Thanks for reading this question and tryin' to help me out. I'm new to the whole threading topic and I'm facing a serious mutex deadlock bug right now.
Short introduction:
I wrote a game engine a few months ago, which works perfectly and is being used in games already. This engine is based on SDL2. I wanted to improve my code by making it thread safe, which would be very useful to increase performance or to play around with some other theoretical concepts.
The problem:
The game uses internal game stages to display different states of a game, like displaying the menu, or displaying other parts of the game. When entering the "Asteroid Game"-stage I recieve an exception, which is thrown by the std::lock_guard constructor call.
The problem in detail:
When entering the "Asteroid Game"-stage a modelGetDirection() function is being called to recieve a direction vector of a model. This function uses a lock_guard to make this function being thread safe. When debugging this code section this is where the exception is thrown. The program would enter this lock_guard constructor and would throw an exception. The odd thing is, that this function is NEVER being called before. This is the first time this function is being called and every test run would crash right here!
this is where the debugger would stop in threadx:
inline int _Mtx_lockX(_Mtx_t _Mtx)
{ // throw exception on failure
return (_Check_C_return(_Mtx_lock(_Mtx)));
}
And here are the actual code snippets which I think are important:
mutex struct:
struct LEMutexModel
{
// of course there are more mutexes inside here
mutex modelGetDirection;
};
engine class:
typedef class LEMoon
{
private:
LEMutexModel mtxModel;
// other mutexes, attributes, methods and so on
public:
glm::vec2 modelGetDirection(uint32_t, uint32_t);
// other methods
} *LEMoonInstance;
modelGetDirection() (engine)function definition:
glm::vec2 LEMoon::modelGetDirection(uint32_t id, uint32_t idDirection)
{
lock_guard<mutex> lockA(this->mtxModel.modelGetDirection);
glm::vec2 direction = {0.0f, 0.0f};
LEModel * pElem = this->modelGet(id);
if(pElem == nullptr)
{pElem = this->modelGetFromBuffer(id);}
if(pElem != nullptr)
{direction = pElem->pModel->mdlGetDirection(idDirection);}
else
{
#ifdef LE_DEBUG
char * pErrorString = new char[256 + 1];
sprintf(pErrorString, "LEMoon::modelGetDirection(%u)\n\n", id);
this->printErrorDialog(LE_MDL_NOEXIST, pErrorString);
delete [] pErrorString;
#endif
}
return direction;
}
this is the game function that uses the modelGetDirection method! This function would control a space ship:
void Game::level1ControlShip(void * pointer, bool controlAble)
{
Parameter param = (Parameter) pointer;
static glm::vec2 currentSpeedLeft = {0.0f, 0.0f};
glm::vec2 speedLeft = param->engine->modelGetDirection(MODEL_VERA, LEFT);
static const double INCREASE_SPEED_LEFT = (1.0f / VERA_INCREASE_LEFT) * speedLeft.x * (-1.0f);
// ... more code, I think that's not important
}
So as mentioned before: When entering the level1ControlShip() function, the programm will enter the modelGetDirection() function. When entering the modelGetDirection() function an exception will be thrown when tryin' to call:
lock_guard<mutex> lockA(this->mtxModel.modelGetDirection);
And as mentioned, this is the first call of this function in the whole application run!
So why is that? I appreciate any help here! The whole engine (not the game) is an open source project and can be found on gitHub in case I forgot some important code snippets (sorry! in that case):
GitHub: Lynar Moon Engine
Thanks for your help!
Greetings,
Patrick

Useless use of private variable in void context in simple perl loop, no idea where the error is

if ( $num_of_things > 1) {
my $max_element = $num_of_things -1;
for($max_element; $max_element >= 0; $max_element--) {
$value_array[$max_element] = $starting_hash{$key}[$max_element];
}
All of my variables not initialized in this code snippet have been initialized as part of the larger subroutine (which I don't want to put up due to length). I'm not sure where I'm getting the useless use of private variable in void context error in this code, my compiler is telling me it's the last line (with nothing but the closing brace "}"). All help is hugely appreciated as I've been staring at this loop for almost an hour with no idea what is wrong.
Move initialization (and declaration) of $max_element into for statement.
[see ooga comment ]
for( my $max_element=$num_of_things-1; $max_element>= 0; $max_element--) {
$value_array[$max_element] = $starting_hash{$key}[$max_element];
}

IONotificationPortCreate not working in Swift

Trying to do some Swift stuff. Converting some USB device detection code from Objective-C to Swift. Having a problem with getting the Notification port. IONotificationPortCreate returns a Unmanaged<'IONotificationPort'>! and when the program runs it hangs on line 2 below and I then printed out the description of notify and notifyPort below. I don't know if it's not getting the port or if I'm not getting it out of that Unmanaged <'IONotificationPort'>! correctly or something else is wrong
var notify = IONotificationPortCreate(kIOMasterPortDefault)
var notifyPort = notify.takeRetainedValue() as IONotificationPortRef
Printing description of notify: (Unmanaged<'IONotificationPort'>!) notify = (_value = <no summary available>)
Printing description of notifyPort: (IONotificationPortRef) notifyPort = 0x000000010050e620 {}
Thanks for any help,
Chris