libpmemobj: setjmp volatile example

24 views
Skip to first unread message

Boylston, Brian

unread,
Jul 29, 2016, 2:30:39 PM7/29/16
to pm...@googlegroups.com
Hi,

In the libpmemobj documentation on transactions:

http://pmem.io/nvml/libpmemobj/libpmemobj.3.html#CAVEATS

a caveat is given regarding the library's use of setjmp/longjmp and
the potential need to qualify some local function variables as "volatile".

The example in the documentation has:

volatile int *good_example = NULL;

However, I am thinking this should be:

int* volatile good_example = NULL;

because we want the pointer itself to be volatile.

Thoughts?


Thanks!
Brian

Krzysztof Czurylo

unread,
Aug 2, 2016, 4:36:56 AM8/2/16
to pmem
Hi Brian,

You're absolutely right! Thank you for pointing this out.

Also, to better illustrate the problem with setjmp/longjmp, pointer variables in this example could be initialized with some invalid addresses, but not NULL. Then, you'll easily observe a segfault on free() for any "bad" non-volatile pointer. Needless to say that the example program must be compiled with optimizations enabled ("-O2") to make this happen.

We will fix the man page. Thanks!

K.
Reply all
Reply to author
Forward
0 new messages