| 519 | } |
| 520 | |
| 521 | void Internal::Dbg_ObjectPreDelete(bf::System::Object* object) |
| 522 | { |
| 523 | BF_ASSERT((BFRTFLAGS & BfRtFlags_ObjectHasDebugFlags) != 0); |
| 524 | |
| 525 | #ifndef BFRT_NODBGFLAGS |
| 526 | const char* errorPtr = NULL; |
| 527 | |
| 528 | if ((object->mObjectFlags & BfObjectFlag_StackAlloc) != 0) |
| 529 | { |
| 530 | if ((object->mObjectFlags & BfObjectFlag_Allocated) == 0) |
| 531 | errorPtr = "Attempting to delete stack-allocated object"; |
| 532 | else |
| 533 | errorPtr = "Deleting an object that was detected as leaked (internal error)"; |
| 534 | } |
| 535 | else if ((object->mObjectFlags & BfObjectFlag_AppendAlloc) != 0) |
| 536 | errorPtr = "Attempting to delete append-allocated object, use 'delete append' statement instead of 'delete'"; |
| 537 | else if ((object->mObjectFlags & BfObjectFlag_Allocated) == 0) |
| 538 | { |
| 539 | errorPtr = "Attempting to delete custom-allocated object without specifying allocator"; |
| 540 | #if _WIN32 |
| 541 | MEMORY_BASIC_INFORMATION stackInfo = { 0 }; |
| 542 | VirtualQuery(object, &stackInfo, sizeof(MEMORY_BASIC_INFORMATION)); |
| 543 | if ((stackInfo.Protect & PAGE_READONLY) != 0) |
| 544 | errorPtr = "Attempting to delete read-only object"; |
| 545 | #endif |
| 546 | } |
| 547 | else if ((object->mObjectFlags & BfObjectFlag_Deleted) != 0) |
| 548 | errorPtr = "Attempting second delete on object"; |
| 549 | |
| 550 | if (errorPtr != NULL) |
| 551 | { |
| 552 | Beefy::String errorStr = errorPtr; |
| 553 | |
| 554 | Beefy::String typeName = object->GetTypeName(); |
| 555 | errorStr += "\x1"; |
| 556 | errorStr += StrFormat("LEAK\t0x%@\n", object); |
| 557 | errorStr += StrFormat(" (%s)0x%@\n", typeName.c_str(), object); |
| 558 | SETUP_ERROR(errorStr.c_str(), 2); |
| 559 | BF_DEBUG_BREAK(); |
| 560 | BFRTCALLBACKS.DebugMessageData_Fatal(); |
| 561 | return; |
| 562 | } |
| 563 | #endif |
| 564 | } |
| 565 | |
| 566 | void Internal::Dbg_ObjectPreCustomDelete(bf::System::Object* object) |
| 567 | { |
nothing calls this directly
no test coverage detected