Skip to content
New issue

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

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

Already on GitHub? # to your account

BUG likely:Create thread using libpthread failed in HHVM extesion #1007

Closed
zhangmuhua opened this issue Sep 1, 2013 · 2 comments
Closed

Comments

@zhangmuhua
Copy link

  1. i want create a thread in HHVM extension but failed.
    code as follows:
    59 int stacksize = 1048576;
    60 int guardsize = 4096;
    61
    62 pthread_t thread1;
    63 void *thread_result;
    64 pthread_attr_t attr;
    65 int res_init = pthread_attr_init(&attr);
    66 int res_detach = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
    67 int res_sstack = pthread_attr_setstacksize(&attr, stacksize);
    68 int res_sguard = pthread_attr_setguardsize(&attr, guardsize);
    69 int res = pthread_create(&thread1, &attr, pfunc, NULL);
    70 sleep(1);
    71 pthread_join(thread1, &thread_result)

However, create failed and core dumped in pthread_create.

  1. we just to adjust pthread_attr_t attr,
    if we set attr = NULL, work ok!!!!
    if we set attr.stacksize=1MB, work failed!!!!!.
    if we set attr.stacksize=2B, work ok!!!!

Is there anything different in HHVM to create a thread using libpthread?? this errors strongly confused me for 3 weeks. And we just read HHVM code involved MemoryManager and some functions involved Initing some params of thread, such as hphp_process_init(), init_thread_locals(), InitAllocatorThreadLocal(), init_stringdata_allocator(). But we couldnot fix this problem. is there anybody to give us some useful idea??
Thanks.

@zhangmuhua
Copy link
Author

if we set attr.stacksize=2B, work ok!!!! --> if we set attr.stacksize=2MB, work ok!!!!

@scannell
Copy link
Contributor

scannell commented Sep 3, 2013

Dupe of #1015.

@scannell scannell closed this as completed Sep 3, 2013
facebook-github-bot pushed a commit that referenced this issue Oct 4, 2024
Summary: [Fix an upstream bug](mozilla/cbindgen#1006) and [add ability to put arbitrary prefix on field names](mozilla/cbindgen#1007).

Reviewed By: jasonwhite

Differential Revision: D63878067

fbshipit-source-id: 16a35ed1fa2adc4c9211fc6f6332f0be7dbf4f56
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants