Skip to content

Commit 3fd2ac0

Browse files
authored
Proper handling thread creation failure (#3063)
1 parent f86e48f commit 3fd2ac0

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

targets/AzureRTOS/ST/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,11 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
580580

581581
if (status != TX_SUCCESS)
582582
{
583-
NANOCLR_SET_AND_LEAVE(CLR_E_PROCESS_EXCEPTION);
583+
// failed to create the thread
584+
// free stack memory
585+
platform_free(palI2c->WorkingThreadStack);
586+
587+
NANOCLR_SET_AND_LEAVE(CLR_E_FAIL);
584588
}
585589

586590
// bump custom state

targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,11 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
583583

584584
if (status != TX_SUCCESS)
585585
{
586-
NANOCLR_SET_AND_LEAVE(CLR_E_PROCESS_EXCEPTION);
586+
// failed to create the thread
587+
// free stack memory
588+
platform_free(palI2c->WorkingThreadStack);
589+
590+
NANOCLR_SET_AND_LEAVE(CLR_E_FAIL);
587591
}
588592

589593
// bump custom state

targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.Device.OneWire/nf_dev_onewire_nanoFramework_Device_OneWire_OneWireHost.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,11 @@ HRESULT FindOneDevice(CLR_RT_StackFrame &stack, bool findFirst)
471471

472472
if (status != TX_SUCCESS)
473473
{
474-
NANOCLR_SET_AND_LEAVE(CLR_E_PROCESS_EXCEPTION);
474+
// failed to create the thread
475+
// free stack memory
476+
platform_free(workingThreadStack);
477+
478+
NANOCLR_SET_AND_LEAVE(CLR_E_FAIL);
475479
}
476480

477481
// bump custom state

0 commit comments

Comments
 (0)