Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

255
Visualizações
How can a non-recursive function appear twice in a stack trace?

I have a function check that is roughly like this:

void check() {
    // ...
    
    // Make some execute-only memory readable for subsequent inspection
    // using the mprotect system call
    mprotect(addr, length, PROT_READ | PROT_EXEC); // #1
    
    // Read the memory and do some integrity checks ...
    if (addr[42] == 13) { // #2
        // ...
    }
}

My program sometimes crashes with a segmentation fault in the line marked with #2, where the memory is read.

When I look at the stack trace, there are two(!) entries of my function check:

  1. Function check, line #2 (where the memory is read)
  2. Function check, line #1 (the mprotect system call)

So according to the stack trace, my function is somehow called from within itself, and that call happens in line #1 where I do the mprotect system call.

How is this possible?

EDIT: As requested, here's the original stack trace:

Crashed: Thread :  SIGSEGV  0x000000752eaba9a8
#00 pc 0xddc08 libnative-49.so (isAnyFunctionBeingHooked(_JNIEnv*, unsigned char const**, unsigned long) [NativeLib.cpp:185])
#01 pc 0xddc00 libnative-49.so (isAnyFunctionBeingHooked(_JNIEnv*, unsigned char const**, unsigned long) [NativeLib.cpp:164])
#02 pc 0xd7b54 libnative-49.so (dFAH(_JNIEnv*) [NativeLib.cpp:267])
// Following entries are outside of my code ...

Line 164 is the call to mprotect. Line 185 is reading the memory previously made readable by mprotect.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda