Fix build.sh race condition #215

Closed
opened 2 years ago by duke · 5 comments
duke commented 2 years ago
Owner

Sometimes build.sh -j N doesn't work because of a race condition

In file included from cryptoconditions/src/asn/Condition.h:17,
                 from cryptoconditions/src/cryptoconditions.c:19:
cryptoconditions/src/asn/SimpleSha256Condition.h:17:10: fatal error: OCTET_STRING.h: No such file or directory
   17 | #include <OCTET_STRING.h>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:2467: cryptoconditions/src/cryptoconditions.lo] Error 1
make[2]: *** Waiting for unfinished jobs....

There needs to be a change to our Makefile which makes something depend on OCTET_STRING.h existing, such as cryptoconditions/src/asn/SimpleSha256Condition.h depending on OCTET_STRING.h existing, because OCTET_STRING.h is a generated file and sometimes the compiler tries to compile code that uses it, before it's been generated.

Sometimes `build.sh -j N` doesn't work because of a race condition ``` In file included from cryptoconditions/src/asn/Condition.h:17, from cryptoconditions/src/cryptoconditions.c:19: cryptoconditions/src/asn/SimpleSha256Condition.h:17:10: fatal error: OCTET_STRING.h: No such file or directory 17 | #include <OCTET_STRING.h> | ^~~~~~~~~~~~~~~~ compilation terminated. make[2]: *** [Makefile:2467: cryptoconditions/src/cryptoconditions.lo] Error 1 make[2]: *** Waiting for unfinished jobs.... ``` There needs to be a change to our Makefile which makes something depend on OCTET_STRING.h existing, such as `cryptoconditions/src/asn/SimpleSha256Condition.h` depending on `OCTET_STRING.h` existing, because `OCTET_STRING.h` is a generated file and sometimes the compiler tries to compile code that uses it, before it's been generated.
Poster
Owner

This is another form of the race condition:

  CC       cryptoconditions/src/utils.o
cryptoconditions/src/utils.c:27:10: fatal error: cryptoconditions.h: No such file or directory
   27 | #include "cryptoconditions.h"
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:2451: cryptoconditions/src/utils.o] Error 1
This is another form of the race condition: ``` CC cryptoconditions/src/utils.o cryptoconditions/src/utils.c:27:10: fatal error: cryptoconditions.h: No such file or directory 27 | #include "cryptoconditions.h" | ^~~~~~~~~~~~~~~~~~~~ compilation terminated. make[2]: *** [Makefile:2451: cryptoconditions/src/utils.o] Error 1 ```
Poster
Owner

Neither OCTET_STRING.h nor cryptoconditions.h are generated files, so something else is going on here.

My current guess is that src/cryptoconditions/src/utils.o needs src/cryptoconditions/src/cryptoconditions.o to exist first

Neither OCTET_STRING.h nor cryptoconditions.h are generated files, so something else is going on here. My current guess is that `src/cryptoconditions/src/utils.o` needs `src/cryptoconditions/src/cryptoconditions.o` to exist first
duke added the
bug
label 1 year ago
Collaborator

I was hitting this on danger branch currently. First failed for missing OCTET_STRING.h, then cryptoconditions.h, and then OCTET_STRING.h again. I was using -j 2 at first and then also hit it again without specifying but it eventually compiled. Might be partially related to VPS as it's only 2 vCPUs and 4 GB RAM.

I was hitting this on `danger` branch currently. First failed for missing OCTET_STRING.h, then cryptoconditions.h, and then OCTET_STRING.h again. I was using `-j 2` at first and then also hit it again without specifying but it eventually compiled. Might be partially related to VPS as it's only 2 vCPUs and 4 GB RAM.
Poster
Owner

This error will go away when the duke branch is merged, which removes libcryptoconditions entirely 🎉

This error will go away when the `duke` branch is merged, which removes libcryptoconditions entirely :hooray:
Poster
Owner

duke branch is merged to dev, this bug is now gone

`duke` branch is merged to `dev`, this bug is now gone
duke closed this issue 3 months ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.