Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault in np.power involving integers and fastmath #9554

Open
2 tasks done
aseyboldt opened this issue May 2, 2024 · 1 comment
Open
2 tasks done

Segfault in np.power involving integers and fastmath #9554

aseyboldt opened this issue May 2, 2024 · 1 comment
Labels
bug - segfault Bugs that cause SIGSEGV, SIGABRT, SIGILL, SIGBUS needtriage

Comments

@aseyboldt
Copy link
Contributor

The following code segfaults on my machine:

import numba
import numpy as np

@numba.jit("float64(float64, int8)", fastmath=True)
def foo(x, y):
    return np.power(x, y)

foo(np.float64(4.), np.int8(2))

It generates the following llvm code:

define i32 @_ZN8__main__3fooB2v3B60c8tJTIeFIjxB2IKSgI4CrvQClYb5wBbdC9XqICn1Wk1gKBZBVGsCAA_3d_3dEda(double* noalias nocapture writeonly %retptr, { i8*, i32, i8*, i8*, i32 }** noalias nocapture readnone %excinfo, double %arg.x, i8 %arg.y) local_unnamed_addr #0 {
for.end:
  %0 = sext i8 %arg.y to i32
  %1 = tail call fast double @llvm.powi.f64.i32(double %arg.x, i32 %0)
  store double %1, double* %retptr, align 8
  ret i32 0
}

Without the fastmath it uses @llvm.pow.f64 with no problems.

The generated assembly calls __powidf2

	pushq	%rbx
	movq	%rdi, %rbx
	movsbl	%dl, %edi
	movabsq	$__powidf2, %rax
	callq	*%rax
	vmovsd	%xmm0, (%rbx)
	xorl	%eax, %eax
	popq	%rbx
	retq

Maybe this is just a variant of this issue, but for some reason I see a segfault instead?

A user also reported seeing the missing symbol error in a related case.

I'm on arch linux, and I see the same problem both with numba from the numba conda channel and from numba installed systemwide from the arch package.

@aseyboldt aseyboldt changed the title Invalid code generation for np.power involving integers and fastmath Segfault in np.power involving integers and fastmath May 2, 2024
@kc611 kc611 added the bug - segfault Bugs that cause SIGSEGV, SIGABRT, SIGILL, SIGBUS label May 7, 2024
@kc611
Copy link
Collaborator

kc611 commented May 7, 2024

Hi @aseyboldt, Thanks for reporting the issue. I can confirm the same locally on a Ubuntu Linux too. Not sure right now from where the error is originating, marking this as needs triage.

Could you please provide some additional information like the CPU info,OS version, libm version, whether SVML was installed or not along with the code/logical path that produces the said error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - segfault Bugs that cause SIGSEGV, SIGABRT, SIGILL, SIGBUS needtriage
Projects
None yet
Development

No branches or pull requests

2 participants