|
7 | 7 | #include <string> |
8 | 8 | #include <exception> |
9 | 9 | #include <cstring> |
| 10 | +#include <cstdio> |
| 11 | +#include <atomic> |
10 | 12 |
|
11 | 13 | extern "C" { |
12 | 14 | // Context management - core functionality required by PyHelios |
@@ -1476,21 +1478,43 @@ extern "C" { |
1476 | 1478 | void setPrimitiveDataInt(helios::Context* context, unsigned int uuid, const char* label, int value) { |
1477 | 1479 | // Clear error state before any operation to prevent contamination from previous calls |
1478 | 1480 | clearError(); |
| 1481 | + |
| 1482 | + // Debug logging for macOS CI investigation |
| 1483 | + fprintf(stderr, "[DEBUG-MACOS] setPrimitiveDataInt: uuid=%u, label=%s, value=%d\n", uuid, label, value); |
| 1484 | + fprintf(stderr, "[DEBUG-MACOS] Initial error state: code=%d\n", getLastErrorCode()); |
| 1485 | + |
1479 | 1486 | try { |
1480 | 1487 | if (!context) { |
1481 | 1488 | setError(PYHELIOS_ERROR_INVALID_PARAMETER, "Context pointer is null"); |
| 1489 | + fprintf(stderr, "[DEBUG-MACOS] ERROR: Context pointer is null\n"); |
1482 | 1490 | return; |
1483 | 1491 | } |
1484 | 1492 | if (!label) { |
1485 | 1493 | setError(PYHELIOS_ERROR_INVALID_PARAMETER, "Label is null"); |
| 1494 | + fprintf(stderr, "[DEBUG-MACOS] ERROR: Label is null\n"); |
1486 | 1495 | return; |
1487 | 1496 | } |
| 1497 | + |
| 1498 | + fprintf(stderr, "[DEBUG-MACOS] About to call context->setPrimitiveData()\n"); |
1488 | 1499 | context->setPrimitiveData(uuid, label, value); |
| 1500 | + |
| 1501 | + // Memory barrier to ensure data write completion before verification |
| 1502 | + std::atomic_thread_fence(std::memory_order_seq_cst); |
| 1503 | + fprintf(stderr, "[DEBUG-MACOS] context->setPrimitiveData() completed successfully with memory barrier\n"); |
| 1504 | + |
| 1505 | + // Immediate verification to debug thread_local storage issue |
| 1506 | + bool exists_immediately = context->doesPrimitiveDataExist(uuid, label); |
| 1507 | + fprintf(stderr, "[DEBUG-MACOS] Immediate verification: exists=%s\n", exists_immediately ? "true" : "false"); |
| 1508 | + |
1489 | 1509 | } catch (const std::exception& e) { |
1490 | 1510 | setError(PYHELIOS_ERROR_RUNTIME, std::string("ERROR (Context::setPrimitiveData): ") + e.what()); |
| 1511 | + fprintf(stderr, "[DEBUG-MACOS] Exception caught: %s\n", e.what()); |
1491 | 1512 | } catch (...) { |
1492 | 1513 | setError(PYHELIOS_ERROR_UNKNOWN, "ERROR (Context::setPrimitiveData): Unknown error setting primitive data int."); |
| 1514 | + fprintf(stderr, "[DEBUG-MACOS] Unknown exception caught\n"); |
1493 | 1515 | } |
| 1516 | + |
| 1517 | + fprintf(stderr, "[DEBUG-MACOS] Final error state: code=%d\n", getLastErrorCode()); |
1494 | 1518 | } |
1495 | 1519 |
|
1496 | 1520 | void setPrimitiveDataString(helios::Context* context, unsigned int uuid, const char* label, const char* value) { |
@@ -1595,23 +1619,42 @@ extern "C" { |
1595 | 1619 | bool doesPrimitiveDataExist(helios::Context* context, unsigned int uuid, const char* label) { |
1596 | 1620 | // Clear error state before any operation to prevent contamination from previous calls |
1597 | 1621 | clearError(); |
| 1622 | + |
| 1623 | + // Debug logging for macOS CI investigation |
| 1624 | + fprintf(stderr, "[DEBUG-MACOS] doesPrimitiveDataExist: uuid=%u, label=%s\n", uuid, label); |
| 1625 | + fprintf(stderr, "[DEBUG-MACOS] Initial error state: code=%d\n", getLastErrorCode()); |
| 1626 | + |
1598 | 1627 | try { |
1599 | 1628 | if (!context) { |
1600 | 1629 | setError(PYHELIOS_ERROR_INVALID_PARAMETER, "Context pointer is null"); |
| 1630 | + fprintf(stderr, "[DEBUG-MACOS] ERROR: Context pointer is null\n"); |
1601 | 1631 | return false; |
1602 | 1632 | } |
1603 | 1633 | if (!label) { |
1604 | 1634 | setError(PYHELIOS_ERROR_INVALID_PARAMETER, "Label is null"); |
| 1635 | + fprintf(stderr, "[DEBUG-MACOS] ERROR: Label is null\n"); |
1605 | 1636 | return false; |
1606 | 1637 | } |
1607 | | - return context->doesPrimitiveDataExist(uuid, label); |
| 1638 | + |
| 1639 | + fprintf(stderr, "[DEBUG-MACOS] About to call context->doesPrimitiveDataExist()\n"); |
| 1640 | + |
| 1641 | + // Memory barrier to ensure any pending writes are visible before reading |
| 1642 | + std::atomic_thread_fence(std::memory_order_acquire); |
| 1643 | + bool result = context->doesPrimitiveDataExist(uuid, label); |
| 1644 | + fprintf(stderr, "[DEBUG-MACOS] context->doesPrimitiveDataExist() returned: %s (with memory barrier)\n", result ? "true" : "false"); |
| 1645 | + |
| 1646 | + return result; |
1608 | 1647 | } catch (const std::exception& e) { |
1609 | 1648 | setError(PYHELIOS_ERROR_RUNTIME, std::string("ERROR (Context::doesPrimitiveDataExist): ") + e.what()); |
| 1649 | + fprintf(stderr, "[DEBUG-MACOS] Exception caught: %s\n", e.what()); |
1610 | 1650 | return false; |
1611 | 1651 | } catch (...) { |
1612 | 1652 | setError(PYHELIOS_ERROR_UNKNOWN, "ERROR (Context::doesPrimitiveDataExist): Unknown error checking primitive data existence."); |
| 1653 | + fprintf(stderr, "[DEBUG-MACOS] Unknown exception caught\n"); |
1613 | 1654 | return false; |
1614 | 1655 | } |
| 1656 | + |
| 1657 | + fprintf(stderr, "[DEBUG-MACOS] Final error state: code=%d\n", getLastErrorCode()); |
1615 | 1658 | } |
1616 | 1659 |
|
1617 | 1660 | void setPrimitiveDataVec3(helios::Context* context, unsigned int uuid, const char* label, float x, float y, float z) { |
|
0 commit comments