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

check SEGV on GNU-C lambda expressions #1848

Open
CN-Zxcv opened this issue Feb 17, 2025 · 0 comments
Open

check SEGV on GNU-C lambda expressions #1848

CN-Zxcv opened this issue Feb 17, 2025 · 0 comments

Comments

@CN-Zxcv
Copy link

CN-Zxcv commented Feb 17, 2025

GNU-C lambda expression check failed with -fsanitize=address。
code below is fine with older libasan like in gcc-toolset-12;but new version report a failure

AddressSanitizer:DEADLYSIGNAL
=================================================================
==3577182==ERROR: AddressSanitizer: SEGV on unknown address 0x7fd35ef00034 (pc 0x7fd35ef00034 bp 0x7ffdca514b00 sp 0x7ffdca514ae8 T0)
==3577182==The signal is caused by a READ memory access.
==3577182==Hint: PC is at a non-executable region. Maybe a wild jump?
    #0 0x7fd35ef00034  (<unknown module>)
    #1 0x5141e0 in main /root/code/test-test/main.c:38
    #2 0x7fd360c2958f in __libc_start_call_main (/lib64/libc.so.6+0x2958f) (BuildId: 8c3b90b6dfac32e7e7da24c75b450ef3be7d48da)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (<unknown module>) 
==3577182==ABORTING

compile command:

gcc main.c -fsanitize=address -static-libasan -g3

gcc version :

gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

source:

#include <stdlib.h>                            
#include <stdio.h>                             
                                               
#define lambda(return_type, function_body) \   
    ({ \                                       
    return_type  __lambda__ function_body \   
    __lambda__ ; \                            
    })                                        
                                               
typedef void (*lambda_func)();                 
                                               
int maby_error(lambda_func func)               
{                                              
    func();                                    
    return 0;                                  
}                                              
                                               
int main(int argc, char *argv[])               
{                                              
    int val_a = 10;                            
    maby_error(lambda(void,() {                
       printf("this is lambda: %d\n", val_a); 
       return;                                
    }));                                       
    return 0;                                  
}                                              
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant