Skip to content

Improve Error Reporting for Premature modDetail Access in HPT

Since HPT is now mutable (merge request #13675 (closed)), fixIO at initModDetails is no longer particularly useful. Moreover, premature access to modDetail (MDI) can result in an uninformative hang, as seen in issue #25858 (closed).

A better approach would be:

  1. Insert a placeholder into HPT that triggers a panic with a more informative error message.
  2. Construct MDI as usual.
  3. Replace the placeholder in HPT with the actual MDI.

With this approach, premature access will produce a clear error message instead of an uninformative hang, making it easier to trace and debug issues like #25858 (closed).

Proposed Change

Replace:

initModDetails hsc_env iface =
  fixIO $ \details' -> do
    add_iface_to_hpt iface details' hsc_env
    genModDetails hsc_env iface

With:

initModDetails hsc_env iface = do
    add_iface_to_hpt iface
      (panic $ "initModDetails: premature access to ModDetail: "
               ++ moduleNameString (moduleName $ mi_module iface))
      hsc_env
    details <- genModDetails hsc_env iface
    add_iface_to_hpt iface details hsc_env
    return details
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information