PRL-PRG / UFOs

User Fault Objects: making vectors lazy and forgetful.
12 stars 3 forks source link

Valgrind VVoes #16

Open kondziu opened 4 years ago

kondziu commented 4 years ago

When running UFOs with valgrind, initialization fails with a confusing error (I'm new to valgrind, I hope this makes sense):

/opt/R-3.6.0/bin/R -d "valgrind --track-origins=yes --keep-stacktraces=alloc-and-free --error-limit=no --num-callers=40"
library(ufoseq)
ufo_seq(1,10,1)
--19530-- WARNING: unhandled amd64-linux syscall: 323
--19530-- You may be able to write your own handler.
--19530-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--19530-- Nevertheless we consider this a bug.  Please report
--19530-- it at http://valgrind.org/support/bug_reports.html.
syscall/userfaultfd: Function not implemented
error initializing User-Fault file descriptor: Function not implemented
Error in ufo_seq(1, 10, 1) : Error initializing the UFO framework (-1)

This also happens when running ufoTest:

valgrind --track-origins=yes --keep-stacktraces=alloc-and-free --error-limit=no --num-callers=40 ./ufoTest 5
==22423== Memcheck, a memory error detector
==22423== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==22423== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==22423== Command: ./ufoTest 5
==22423== 
--22423-- WARNING: unhandled amd64-linux syscall: 323
--22423-- You may be able to write your own handler.
--22423-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--22423-- Nevertheless we consider this a bug.  Please report
--22423-- it at http://valgrind.org/support/bug_reports.html.
syscall/userfaultfd: Function not implemented
error initializing User-Fault file descriptor: Function not implemented
x.x: Function not implemented
Err Init: Function not implemented
==22423== 
==22423== HEAP SUMMARY:
==22423==     in use at exit: 82,208 bytes in 4 blocks
==22423==   total heap usage: 12 allocs, 8 frees, 88,512 bytes allocated
==22423== 
==22423== LEAK SUMMARY:
==22423==    definitely lost: 0 bytes in 0 blocks
==22423==    indirectly lost: 0 bytes in 0 blocks
==22423==      possibly lost: 0 bytes in 0 blocks
==22423==    still reachable: 82,208 bytes in 4 blocks
==22423==         suppressed: 0 bytes in 0 blocks
==22423== Rerun with --leak-check=full to see details of leaked memory
==22423== 
==22423== For counts of detected and suppressed errors, rerun with: -v
==22423== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
kondziu commented 4 years ago

I checked without valgrind.

__ufo_system = ufMakeInstance() returns 0x0, but ufInit(__ufo_system) returns result == 0

My understanding was that ufInit checks for NULL, but it turns out it doesn't. In fact ufMakeInstance should be checking for null before it starts allocating stuff inside the instance.

electroCutie commented 4 years ago

WARNING: unhandled amd64-linux syscall: 323

Reference for syscall numbers here: https://gist.github.com/yamnikov-oleg/454f48c3c45b735631f2 323 on amd64 is the userfaultd syscall This line in our code is where it is called int uffd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);

This is core and critical and cannot be avoided