Skip to content

Dynlink.loadfile should dlclose on error #14323

@lefessan

Description

@lefessan

I am doing the following steps in a single execution:

  1. Trying to load Dynlink.loadfile toto.cmxs, which errors with Inconsistent_import ...
  2. Rebuilding toto.cmxs from toto.ml, thus fixing the inconsistencies
  3. Trying to load it again (the new generated toto.cmxs), but the same error happens
  4. Restarting the same program, no more errors with the latest toto.cmxs

My understanding is that the program does not forget the first attempt, thus always returning the same error, even if the second dynlink should actually work. This happens both with loadfile and loadfile_private.

I think that loadfile should dlclose when the attempt fails (and maybe do some other cleanup for other errors), so that the retry can correctly work.

As a side note, it would be really nice to expose a more low-level interface on Dynlink, typically to expose the CRCs of the current state and the CRCs of successful and failed dynamic linkings. It would make debugging this kind of situations much easier.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions