Page MenuHomeFreeBSD

Add some tests for page fault signals and codes

Authored by jilles on Sep 12 2019, 7:53 PM.



It is useful to have some tests for page fault signals.

More tests would be useful but creating the conditions (such as various kinds
of running out of memory and I/O errors) is more complicated.

The test page_fault_signal__bus_objerr_1 depends on
before it can pass.

PR: 211924

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jilles created this revision.Sep 12 2019, 7:53 PM
kib added inline comments.Sep 13 2019, 7:20 AM
58 ↗(On Diff #62004)

Why is this sigfillset needed ?

82 ↗(On Diff #62004)

Perhaps add volatile somewhere ? Or use C11 atomic_store relaxed.

84 ↗(On Diff #62004)

I wonder if we want to be more formal there, and add a fence before accesses to last_sig and last_code.

140 ↗(On Diff #62004)

Don't you need to truncate shmfd before access ?

kib added inline comments.Sep 13 2019, 7:34 AM
140 ↗(On Diff #62004)

I see, you did not extended shmfd at all. I think it would be more interesting to ensure that at least one page is allowed.

jilles updated this revision to Diff 62135.Sep 15 2019, 9:51 PM

Add another testcase for access past end of non-empty object

jilles marked 3 inline comments as done.Sep 16 2019, 9:54 PM
jilles added inline comments.
58 ↗(On Diff #62004)

To prevent the signal handler being entered again between siglongjmp and sigsetjmp.

This is not a very strong reason, but I need to initialize sa.sa_mask in any case.

82 ↗(On Diff #62004)

Not sure if that's needed, given that mmap() and munmap() are not magical the way malloc() and free() are, but I'm adding it anyway.

84 ↗(On Diff #62004)

last_sig and last_code are volatile, which should suffice for communication with a signal handler in the same thread.

jilles updated this revision to Diff 62186.Sep 16 2019, 9:56 PM
jilles marked an inline comment as done.

Add more volatile

kib accepted this revision.Sep 17 2019, 7:43 AM
kib added inline comments.
84 ↗(On Diff #62004)

volatile semantic for gcc and clang only guarantee that the access occurs, it does not provide any guarantee when.

This revision is now accepted and ready to land.Sep 17 2019, 7:43 AM
This revision was automatically updated to reflect the committed changes.