@@ -177,16 +177,16 @@ impl Slot {
177177 //
178178 // See #169.
179179
180- new. sa_sigaction = handler as usize ; // If it doesn't compile on AIX, upgrade the libc dependency
180+ new. sa_sigaction = handler as * const ( ) as usize ; // If it doesn't compile on AIX, upgrade the libc dependency
181181
182- // Android is broken and uses different int types than the rest (and different depending on
183- // the pointer width). This converts the flags to the proper type no matter what it is on
184- // the given platform.
185182 #[ cfg( target_os = "nto" ) ]
186183 let flags = 0 ;
187- // SA_RESTART is supported by qnx https://www.qnx.com/support/knowledgebase.html?id=50130000000SmiD
184+ // SA_RESTART is not supported by qnx https://www.qnx.com/support/knowledgebase.html?id=50130000000SmiD
188185 #[ cfg( not( target_os = "nto" ) ) ]
189186 let flags = libc:: SA_RESTART ;
187+ // Android is broken and uses different int types than the rest (and different depending on
188+ // the pointer width). This converts the flags to the proper type no matter what it is on
189+ // the given platform.
190190 #[ allow( unused_assignments) ]
191191 let mut siginfo = flags;
192192 siginfo = libc:: SA_SIGINFO as _ ;
@@ -246,9 +246,13 @@ impl Prev {
246246 fn execute ( & self , sig : c_int ) {
247247 let fptr = self . info ;
248248 if fptr != 0 && fptr != SIG_DFL && fptr != SIG_IGN {
249+ // `sighandler_t` is an integer type. Transmuting it directly from an integer to a
250+ // function pointer seems dubious w.r.t. pointer provenance -- at least Miri complains
251+ // about it. Casting to a raw pointer first side-steps the issue.
252+ let fptr = fptr as * mut ( ) ;
249253 // FFI ‒ calling the original signal handler.
250254 unsafe {
251- let action = mem:: transmute :: < usize , extern "C" fn ( c_int ) > ( fptr) ;
255+ let action = mem:: transmute :: < * mut ( ) , extern "C" fn ( c_int ) > ( fptr) ;
252256 action ( sig) ;
253257 }
254258 }
@@ -258,6 +262,10 @@ impl Prev {
258262 unsafe fn execute ( & self , sig : c_int , info : * mut siginfo_t , data : * mut c_void ) {
259263 let fptr = self . info . sa_sigaction ;
260264 if fptr != 0 && fptr != libc:: SIG_DFL && fptr != libc:: SIG_IGN {
265+ // `sa_sigaction` is usually stored as integer type. Transmuting it directly from an
266+ // integer to a function pointer seems dubious w.r.t. pointer provenance -- at least
267+ // Miri complains about it. Casting to a raw pointer first side-steps the issue.
268+ let fptr = fptr as * mut ( ) ;
261269 // Android is broken and uses different int types than the rest (and different
262270 // depending on the pointer width). This converts the flags to the proper type no
263271 // matter what it is on the given platform.
@@ -269,11 +277,11 @@ impl Prev {
269277 let mut siginfo = self . info . sa_flags ;
270278 siginfo = libc:: SA_SIGINFO as _ ;
271279 if self . info . sa_flags & siginfo == 0 {
272- let action = mem:: transmute :: < usize , extern "C" fn ( c_int ) > ( fptr) ;
280+ let action = mem:: transmute :: < * mut ( ) , extern "C" fn ( c_int ) > ( fptr) ;
273281 action ( sig) ;
274282 } else {
275283 type SigAction = extern "C" fn ( c_int , * mut siginfo_t , * mut c_void ) ;
276- let action = mem:: transmute :: < usize , SigAction > ( fptr) ;
284+ let action = mem:: transmute :: < * mut ( ) , SigAction > ( fptr) ;
277285 action ( sig, info, data) ;
278286 }
279287 }
0 commit comments