help wanted
Metriche repository
- Star
- (27.361 star)
- Metriche merge PR
- (Merge medio 19g 10h) (147 PR mergiate in 30 g)
Descrizione
The following test code runs perfectly fine when compiled with clang and ran, but when ran with emscripten the ftruncate operation throws a Permission error instead of going through as expected.
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
int main() {
int fd = 0;
char filename[] = "XXXXXX";
// Test
assert((fd = mkstemp(filename)) >= 0);
assert(chmod(filename, 0) >= 0);
assert(ftruncate(fd, 69) >= 0);
// Cleanup
assert(close(fd) >= 0);
assert(remove(filename) >= 0);
printf("ok\n");
return 0;
}
Ran with
clang main.c -o testfs && ./testfsemcc main.c -s ENVIRONMENT=node -s MAIN_MODULE -o out.js && node out.js
Current behavior
Clang build prints ok, emcc build fails (assertion error at ftruncate)
Expected behavior
Both should print "ok"
Environment
OS: Arch Linux clang version 12.0.1 emscripten version 2.0.26 (with clang 13.0.0) node version 16.4.2